ansible模块--fetch模块

fetch模块
将被控端得指定文件,拉取到Ansible服务器
src: 被控端源文件
dest: 主控端目录位置
1.拉取一个/tmp/test.txt 到ansible服务器端https://www.cndba.cn/hbhe0316/article/18874

https://www.cndba.cn/hbhe0316/article/18874
https://www.cndba.cn/hbhe0316/article/18874
https://www.cndba.cn/hbhe0316/article/18874
https://www.cndba.cn/hbhe0316/article/18874
https://www.cndba.cn/hbhe0316/article/18874
[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主控端https://www.cndba.cn/hbhe0316/article/18874https://www.cndba.cn/hbhe0316/article/18874

https://www.cndba.cn/hbhe0316/article/18874
https://www.cndba.cn/hbhe0316/article/18874
[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'.  If
you 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 to
get 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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值