当前位置:网站首页>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 rsa
Then 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
边栏推荐
猜你喜欢
随机推荐
关于如何向FastAPI的依赖函数添加参数
【Flask】Flask-SQLAlchemy的增删改查(CRUD)操作
3559. 围圈报数
用C语言来实现五子棋小游戏
Delightful Nuxt3 Tutorial (1): Application Creation and Configuration
运行 npm run xxx 如何触发构建命令以及启动Node服务等功能?
Makefile语法
Haproxy服务监控
轨迹(形状)相似性判断与度量方法
高效率科研神器——小软件、大能量
跨域错误的原因及处理方法
7.17(7)
1230: 蜂巢
详解Nurbs曲线
Pr第二次培训笔记
【DC-2靶场渗透】
【三子棋】7.25
一维数组和二维数组的命名以及存储空间
-最高分-
【数组】arr,&arr,arr+1,&arr+1以及内存单元的占用