一、Ansible工作机制
二、Ansible执行流程
三、安装Ansible
yum install epel-release
yum install ansible
四、配置
4.1、配置管理主机
vim /etc/ansible/hosts
在hosts文件中添加管理主机的IP地址列表:
4.2、配置控制主机SSH密钥
4.2.1、在控制主机中生成ssh密钥对
ssh-keygen -t rsa
4.2.2、将公钥拷贝到管理主机中.ssh/authorized_keys文件中,实现免密码登录远程管理主机
ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.0.2
4.2.3、ansible配置
vim /etc/ansible/ansible.cfg
禁用每次执行ansbile命令检查ssh key host
host_key_checking = False
开启日志记录
log_path = /var/log/ansible.log
ansible连接加速配置
[accelerate]
#accelerate_port = 5099
accelerate_port = 10000
#accelerate_timeout = 30
#accelerate_connect_timeout = 5.0
# If set to yes, accelerate_multi_key will allow multiple
# private keys to be uploaded to it, though each user must
# have access to the system via SSH to add a new key. The default
# is "no".
accelerate_multi_key = yes
五、测试
ansible all -m ping
网友评论