1、yum 安装
yum -y install epel-release
yum -y install ansible
ansible 配置秘钥
ssh-keygen -t rsa #直接回车不用设置密码
公钥copy 到需要批量的主机上
[root@vick ~]# ssh-copy-id -i /root/.ssh/id_rsa.pub root@192.168.99.130 [root@vick ~]# ssh-copy-id -i /root/.ssh/id_rsa.pub root@192.168.99.180
2、ansible 基本使用
(1)ansible 执行远程命令
[root@vick ansible]# ansible -i /etc/ansible/hostname all -m command -a 'hostname' 192.168.99.180 | SUCCESS | rc=0 >> ansible.vick02.com 192.168.99.130 | SUCCESS | rc=0 >> ansible.vick01.com