安装ansible
ansible是用python开发的,使用pip来安装,最后指定ansible的版本号
pip3 install ansible==2.9.1
配置
mkdir /root/myansible
cd /root/myabsible
vim ansible.cfg
[defaults]
inventory = hosts
remote_user = root
vim hosts
[dbserver]
db1
[webserver]
web1
vim /etc/hosts
192.168.1.10 db1
192.168.1.50 web1
ssh-keygen
ssh-copy-id root@192.168.1.10
ssh-copy-id root@192.168.1.50
sed -i 's/# StrictHostKeyChecking ask/StrictHostKeyChecking no/' /etc/ssh/ssh_config
sed -i 's/GSSAPIAuthentication yes/GSSAPIAuthentication no/' /etc/ssh/ssh_config
systemctl restart sshd
测试
ansible all -m ping