实验目的使用一台服务器安装Ansible来管理另外两台
Ansible服务端:192.168.31.10
节点:192.168.31.20 192.168.31.21
安装Ansible
1.安装elep源
yum -y install epel-release
2.安装Asible
yum -y install ansible
配置
1.设置ssh密钥,复制公钥到节点
ssh-keygen #一路回车生成密钥
ssh-copy-id -i root@192.168.31.20
ssh-copy-id -i root@192.168.31.21
2.配置ansible文件 /etc/ansible/hosts
[test-servers]
192.168.31.20
192.168.31.21
3.测试ansible
[root@qian1 ~] ansible -m ping 'test-servers'
192.168.31.21 | SUCCESS => {
"changed": false,
"ping": "pong"
}
^H192.168.31.20 | SUCCESS => {
"changed": false,
"ping": "pong"
}