Ansible安装部署
4台虚拟机 ,全部开启防火墙
server 192.168.8.130
node1 192.168.8.131
node2 192.168.8.132
node3 192.168.8.133
1.server部署
[root@server ~]# cd /etc/yum.repos.d/
[root@server yum.repos.d]# rm -rf *
[root@server yum.repos.d]# dnf -y install centos-release-ansible-29-1-
2.el8.noarch
[root@server yum.repos.d]# ls /etc/yum.repos.d/ |grep ansible
CentOS-SIG-ansible-29.repo
[root@server yum.repos.d]# dnf -y install ansible
[root@servere yum.repos.d]# ls
CentOS-Base.repo CentOS-SIG-ansible-29.repo
//查看ansible版本
[root@server yum.repos.d]# ansible --version
ansible 2.9.27
config file = /home/student/ansible/ansible.cfg
configured module search path = ['/home/student/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3.6/site-packages/ansible
executable location = /usr/bin/ansible
python version = 3.6.8 (default, Dec 3 2020, 18:11:24) [GCC 8.4.1 20200928 (Red Hat 8.4.1-1)]
2.配置/etc/hosts
在ansible节点vim /etc/hosts
[root@ansible yum . repos .d]# cd
[root@ansible ~]# vim /etc/hosts
(末行添加)
192.168.8.130 server.example.com server
192.168.8.131 node1.example.com node1
192.168.8.132 node2.example.com node2
192.168.8.133 node3.example.com node3
3.配置ssh的基于密钥认证
在ansible节点执行ssh-keygen命令,一直回车
[root@ansible ~]# ssh-keygen
[student@server ansible]$ ssh-copy-id -i ~/.ssh/id_rsa.pub student@node1
/usr/bin/ssh-copy-id: INFO: Source o