安装 ansible
一、准备三台Linux机器:
server.example.com
node1.example.com
node2.example.com
在对应的三台Linux机器上,修改成自己想要的主机名:
[root@localhost ~]# hostnamectl set-hostname server.example.com
[root@localhost ~]# hostnamectl set-hostname node1.example.com
[root@localhost ~]# hostnamectl set-hostname node2.example.com
二、配置:
- 配置IP:
[root@node1 ~]# nmcli c show ens160 | grep method
ipv4.method: auto
ipv6.method: auto
proxy.method: none
[root@node1 ~]# nmcli c modify ens160 ipv4.addresses 192.168.126.130/24 ipv4.gateway 192.168.126.2 ipv4.dns 8.8.8.8 ipv4.method manual
[root@node1 ~]# nmcli c show ens160 | grep method
ipv4.method: manual
ipv6.method: auto
proxy.method: none
确保ip为静态
2. 在三台主机上 配置 /etc/hosts 让主机名映射到对应的ip:
echo "192.168.126.128 server.example.com" >> /etc/hosts
echo "192.168.126.130 node1.example.com" >> /etc/hosts
echo "192.168.126.129 node2.example.com" >> /etc/hosts
打开 /etc/hosts 进行配置:
三、配置免密登录
- 生成密钥
[root@server ~]# ssh-keygen -t rsa
在 /root/.ssh 查看密钥:
2. 把公钥拷贝到要登录的机器端:
[root@server .ssh]# ssh-copy-id root@node1.example.com
[root@server .ssh]# ssh-copy-id root@node2.example.com
四、配置yum源使用Centos-stream.repo
- 用xftp将 Centos-stream.repo 移动到 /etc/yum.repos.d
没有这个源的,可以私信骚扰我!!!
查看一下:
- 清理缓存:
[root@server yum.repos.d]# yum clean all
3. 创建缓存:
[root@server yum.repos.d]# yum makecache
五、安装两个软件软:
[root@server yum.repos.d]# rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/6.0/rhel/8/x86_64/zabbix-
release-6.0-1.el8.noarch.rpm
[root@server yum.repos.d]# yum install -y https://mirrors.tuna.tsinghua.edu.cn/epel/epel-release-latest-8.noarch.rpm
查看一下:
下载新的源之后,记得清空缓存和重建缓存
六、安装ansible:
[root@server yum.repos.d]# yum install ansible -y
时间可能很漫长,耐心等待。。。。
七、验证:
[root@server yum.repos.d]# ansible --version