- 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'