Ansible命令模塊(unarchive模塊 archive模塊 )


 

1.unarchive 解壓模塊

1)幫助語法

- name: Unarchive a file that is already on the remote machine unarchive: src: /tmp/foo.zip #要解壓的包 dest: /usr/local/bin #解壓到目標位置 remote_src: yes #要解壓的包在受控端 no #要解壓的包在控制端

2)實例

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

 

2.archive 壓縮模塊

1)幫助語法

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 #指定打包的類型

2)實例

#1.打包站點目錄 [root@m01 /package]# ansible web01 -m archive -a 'path=/code dest=/tmp/code.tar.gz'

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM