一、安装ansible软件
1、通过yum源来安装
yum install ansible
2、查看安装的版本
ansible –version
3、配置主机组
Ansible工具默认主目录为/etc/ansible/,其中hosts文件为被管理机IP或者主机名列
二、配置免秘钥登录
1、管理主机上生成秘钥
ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
73:80:07:fa:9a:0d:e0:0e:d1:c2:44:d2:d2:61:67:21 root@ansible
The key’s randomart image is:
+–[ RSA 2048]—-+
|o=E.+.. |
|=oo+ . o |
|ooo . . o |
| + . . . . |
|. . . . S . |
| o = o |
| . o . |
| |
| |
+—————–+
2、将管理机上生成的秘钥发送到被管理机
ssh-copy-id -i /root/.ssh/id_rsa.pub root@192.168.207.137
ssh-copy-id -i /root/.ssh/id_rsa.pub root@192.168.207.132
3、测试是否配置成功
ansible -k all -m ping