功能:解压缩,这个模块有两种用法:
1、将ansible主机上的压缩包在本地解压缩后传到远程主机上,这种情况下,copy=yes. 本地解压缩,解压缩位置不是默认的目录,没找到或传完删了 后传到远程主机
2、将远程主机上的某个压缩包解压缩到指定路径下。这种情况下,需要设置copy=no 远程主机上面的操作,不涉及ansible服务端
参数:
copy:默认为yes,当copy=yes,那么拷贝的文件是从ansible主机复制到远程主机上的,如果设置为copy=no,那么会在远程主机上寻找src源文件
src:源路径,可以是ansible主机上的路径,也可以是远程主机上的路径,如果是远程主机上的路径,则需要设置copy=no
dest:远程主机上的目标路径
mode:设置解压缩后的文件权限
#ansible-doc unarchive
> UNARCHIVE
The [unarchive] module copies an archive file from the local machine
to a remote and unpacks it.
Options (= is mandatory):
- copy
Should the file be copied from the local to the remote
machine? (Choices: yes, no) [Default: yes]
- creates
a filename, when it already exists, this step will *not* be
run. [Default: None]
= dest
Remote absolute path where the archive should be unpacked
[Default: None]
= src
Local path to archive file to copy to the remote server; can
be absolute or relative. [Default: None]
Notes: requires `tar'/`unzip' command on target hostcan handle `gzip',
`bzip2' and `xz' compressed as well as uncompressed tar
filesdetects type of archive automaticallyuses tar's `--diff
arg' to calculate if changed or not. If this `arg' is not
supported, it will always unpack the archivedoes not detect if
a .zip file is different from destination - always
unzipsexisting files/directories in the destination which are
not in the archive are not touched. This is the same behavior
as a normal archive extractionexisting files/directories in
the destination which are not in the archive are ignored for
purposes of deciding if the archive should be unpacked or not
# Example from Ansible Playbooks
- unarchive: src=foo.tgz dest=/var/lib/foo
# Unarchive a file that is already on the remote machine
- unarchive: src=/tmp/foo.zip dest=/usr/local/bin copy=no
unarchive模块 http://docs.ansible.com/ansible/latest/modules/unarchive_module.html