1.配置IP,主机名,/etc/hosts
server
hostnamectl set-hostname server.example.com
node1
hostnamectl set-hostname node1.example.com
nmcli c modify ens160 ipv4.addresses 192.168.86.5/24 ipv4.gateway 192.128.86.2 ipv4.dns 8.8.8.8 ipv4.method manual
node2
hostnamectl set-hostname node2.example.com
nmcli c modify ens160 ipv4.addresses 192.168.86.4/24 ipv4.gateway 192.128.86.2 ipv4.dns 8.8.8.8 ipv4.method manual
在server上配置/etc/hosts
vim /etc/hosts
2.然后去配置免密登录
让server产生公钥私钥
ssh-keygen -t rsa
将server的公钥传给node1主机
3.配置yum源使用Centos-stream.repo
清理缓存yum clean all
重建yum makecache
4.安装ansible
yum install ansible -y
5.使用ansible --version去验证
6.配置清单:/etc/ansible/hosts
7.使用ansible node -m ping去验证