蔬菜小程序的开发全流程详解
796
2022-10-10
ansible模块--fetch模块
fetch模块将被控端得指定文件,拉取到Ansible服务器src: 被控端源文件dest: 主控端目录位置1.拉取一个/tmp/test.txt 到ansible服务器端
[root@ansible tmp]# ansible mysql -m fetch -a 'src=/tmp/test.txt dest=/tmp'192.168.56.88 | CHANGED => { "changed": true, "checksum": "da39a3ee5e6b4b0d3255bfef95601890afd80709", "dest": "/tmp/192.168.56.88/tmp/test.txt", "md5sum": "d41d8cd98f00b204e9800998ecf8427e", "remote_checksum": "da39a3ee5e6b4b0d3255bfef95601890afd80709", "remote_md5sum": null}
2.拉取被控端 以 .log结尾得所有文件。由于 此模板只能拉取一个文件,所以将所有得log日志打包后,拉取到Ansible主控端
[root@ansible tmp]# ansible mysql -m shell -a 'tar -czvf /root/logs.tar.gz /var/log/*.log'[WARNING]: Consider using the unarchive module rather than running 'tar'. Ifyou need to use command because unarchive is insufficient you can add 'warn:false' to this command task or set 'command_warnings=False' in ansible.cfg toget rid of this message.192.168.56.88 | CHANGED | rc=0 >>/var/log/boot.log/var/log/yum.logtar: Removing leading `/' from member names[root@ansible tmp]# ansible mysql -m fetch -a 'src=/root/logs.tar.gz dest=/tmp'192.168.56.88 | CHANGED => { "changed": true, "checksum": "db8f8426b4f71add2c961eab80abb31c12d06da9", "dest": "/tmp/192.168.56.88/root/logs.tar.gz", "md5sum": "266b0bd1a882dda27488d2abc48092f4", "remote_checksum": "db8f8426b4f71add2c961eab80abb31c12d06da9", "remote_md5sum": null}[root@ansible tmp]# ll /tmp/192.168.56.88/root/logs.tar.gz -rw-r--r-- 1 root root 144 Nov 14 11:26 /tmp/192.168.56.88/root/logs.tar.gz
ansible
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~