Ansible命令模組(unarchive模組 archive模組 )
阿新 • • 發佈:2020-10-07
- name: Unarchive a file that is already on the remote machine
unarchive:
src: /tmp/foo.zip #要解壓的包
dest: /usr/local/bin #解壓到目標位置
remote_src:
yes #要解壓的包在受控端
no #要解壓的包在控制端
#1.解壓控制端的包到受控端
[root@m01 /package]# ansible web01 -m unarchive -a 'src=/package/php.tar.gz dest=/tmp/'
#2.解壓受控端的包到受控端
[root@m01 /package]# ansible web03 -m unarchive -a 'src=/package/php.tar.gz dest=/tmp/ remote_src=yes'
EXAMPLES:
- name: Compress directory /path/to/foo/ into /path/to/foo.tgz
archive:
path: /path/to/foo #要壓縮的檔案或目錄
dest: /path/to/foo.tgz #壓縮後的檔案
format:bz2, gz, tar, xz, zip #指定打包的型別
#1.打包站點目錄
[root@m01 /package]# ansible web01 -m archive -a 'path=/code dest=/tmp/code.tar.gz'