ansible unarchive模块
功能:解压缩,这个模块有两种用法: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
热门日志
分类
- Django(4)
- ssdb(1)
- Mac(7)
- C(1)
- memcache(1)
- Python(32)
- Vim(8)
- sed(2)
- ansible(3)
- awk(4)
- shell(3)
- about(1)
- git(9)
- bat(4)
- svn(0)
- docker(1)
- Tornado(1)
- go(2)
- 架构(18)
- Vue(1)
- game(2)
- Html(6)
- Java(8)
- Mysql(37)
- Ajax(2)
- Jsp(1)
- Struts(8)
- Linux(72)
- JavaScript(39)
- Staruml(0)
- Mouth(1)
- Php(102)
- Windows(8)
- Message(48)
- Lua(10)
- Compute(1)
- Redis(7)
- Nginx(12)
- Jquery(1)
- Apache(1)
- cocos2d-x(8)