ansible日常小结

一、ansible优化

vim /etc/ansible/ansible.cfg

host_key_checking = False   #不进行验证
log_path = /var/log/ansible.log  #打开日志 

基于ssh

vim /etc/ssh/sshd_config

UseDNS no
#重启sshd 
# systemctl restart sshd

二、常用模块

1、coyp 模块

ansible date -m copy -a 'src=/etc/selinux/config dest=/etc/selinux/confi

2、fetch模块 从客户端取文件 

ansible date -m fetch -a "src=/var/log/cron dest=/data/"

3、shell模块(执行命令、或者执行远程脚本)、也这样代替file模块

ansible date -m shell -a 'cat /etc/selinux/config'

4、script模块(远程不需要有脚本,控制端有可以)

ansible date -m script -a "/root/scripts/test.sh"

[root@linux-node1 scripts]# cat /root/scripts/test.sh
#!/bin/bash
hostname

 

 

猜你喜欢

转载自www.cnblogs.com/zhaojingyu/p/12114788.html
今日推荐