当前位置:网站首页>Ansible installation and deployment detailed process, basic operation of configuration inventory
Ansible installation and deployment detailed process, basic operation of configuration inventory
2022-08-03 05:40:00 【Xiao Chen loves exercise】
准备三台机器:
server.example.com
node1.example.com
node2.example.com
The first is cloning3台机器,最好是配置好yum源的,serverMachines need to haveansible,ssh,The other two are requiredssh和python

直接克隆就可以
配置IP,主机名,/etc/hosts
Manually configure the three machines separatelyip,使其设置为method
nmcli connection add ipv4.addresses 192.168.38.128 ipv4.gateway 192.168.38.2 ipv4.dns 8.8.8.8 ipv4.method
nmcli connection add ipv4.addresses 192.168.38.130 ipv4.gateway 192.168.38.2 ipv4.dns 8.8.8.8 ipv4.method
nmcli connection add ipv4.addresses 192.168.38.132 ipv4.gateway 192.168.38.2 ipv4.dns 8.8.8.8 ipv4.method
Set the hostname for each of the three machines
hostnamectl set-hostname server.example.com
hostnamectl set-hostname node1.example.com
hostnamectl set-hostname node2.example.com
配置主机名和IP地址的映射关系
Enter the following codes on each of the three machines
[[email protected] ~]# echo "192.168.38.128 server.example.com" >> /etc/hosts
[[email protected] ~]# echo "192.168.38.130 node2.example.com" >> /etc/hosts
[[email protected] ~]# echo "192.168.38.132 node1.example.com" >> /etc/hosts
Then go to configure password-free login
Password-free login is allowedserverThis machine can log in to other machines without password
First generate the key
[[email protected] ~]# ssh-keygen -t rsaThen pass the public key to the remaining two machines
ssh-copy-id [email protected]
ssh-copy-id [email protected]
At this point, you can log in without a password,测试如下
[[email protected] ~]# ssh [email protected]
Activate the web console with: systemctl enable --now cockpit.socket
This system is not registered to Red Hat Insights. See https://cloud.redhat.com/
To register this system, run: insights-client --register
Last login: Tue Aug 2 16:41:14 2022 from 192.168.38.128
[[email protected] ~]#
[[email protected] ~]# ssh [email protected]
Activate the web console with: systemctl enable --now cockpit.socket
This system is not registered to Red Hat Insights. See https://cloud.redhat.com/
To register this system, run: insights-client --register
Last login: Tue Aug 2 16:41:14 2022 from 192.168.38.128
[[email protected] ~]#
配置yum源使用Centos-stream.repo
我们需要将Centos-stream.repo下载到/etc/yum.repos.d/上
首先将原有的Centos-vault-8.5.2111.repoAdding a suffix will not take effect at this time
mv Centos-vault-8.5.2111.repo Centos-vault-8.5.2111.repo.bak然后将windows上的传入linux
C:\Users\Chen Zhixing>sftp [email protected]
[email protected]'s password:
Connected to 192.168.38.128.
sftp> put D:\CentOS-Stream.repo /etc/yum.repos.d/
Uploading D:/CentOS-Stream.repo to /etc/yum.repos.d/CentOS-Stream.repo
D:/CentOS-Stream.repo 100% 1215 1.2MB/s 00:00
sftp>
安装ansible
rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/6.0/rhel/8/x86_64/zabbix-release-6.0-1.el8.noarch.rpm第二步安装
https://mirrors.tuna.tsinghua.edu.cn/epel/epel-release-latest-8.noarch.rpm
yum install https://mirrors.tuna.tsinghua.edu.cn/epel/epel-release-latest-8.noarch.rpm最后一步就是安装ansible
yum install ansible -y
使用ansible --version去验证

配置清单:
[node]
node1.example.com
node2.example.com
使用ansible node -m ping去验证
vim /etc/ansible/hosts
It is now complete to verify
边栏推荐
猜你喜欢
随机推荐
A-B数对问题|UPC-Count Interval|洛谷-P1102A-B数对
【打印菱形】
关于semantic-ui的cdn失效问题(怎样通过本地引用semantic-ui)
Djiango第二次培训
判断回文数
Flask,7
《录取通知》 观后感
亲身分享一次 字节跳动 真实面试经历和面试题
pta a.1003 的收获
C-PHY速率
【myPow,2次幂,3次幂..代码实现】
HarmonyOS应用开发培训第二次作业
7.24[C语言零基础 知识点总结]
pta a.1030的dijkstra+DFS方法
传说中可“免费白拿”的无线路由器 - 斐讯 K2 最简单刷 breed 与第三方固件教程
7.7(5)
Haproxy服务监控
初识C语言
HarmonyOS应用开发第一次培训
【数组】arr,&arr,arr+1,&arr+1以及内存单元的占用









