Ansible多主机添加

一、介绍

1.含义:

ansible是是一个"配置管理工具",它是一个"自动化运维工具",是运维人员的瑞士军刀,可以帮助我们完成一些批量工作或者重复性工作,ansible通过ssh管理其他受管主机,并且具有一些特性,比如幂等性、剧本、模板,角色等。

二、安装ansible

1.管理端安装ansible

bash 复制代码
systemctl stop firewalld.service 
setenforce 0
yum install -y epel-release
yum install -y ansible

2.ansible 目录结构

bash 复制代码
ls /etc/ansible/
├── ansible.cfg			#ansible的配置文件,一般无需修改
├── hosts				#ansible的主机清单,用于存储需要管理的远程主机的相关信息
└── roles/				#公共角色目录

3.配置主机清单

bash 复制代码
vim /etc/ansible/hosts   
[webservers]			#配置组名可自定义,取消注释
192.168.174.15  #组里包含的被管理的主机IP地址或主机名(主机名需要先修改/etc/hosts文件)
192.168.174.16
192.168.174.17
192.168.174.18
192.168.174.19
192.168.174.20
			
[dbservers]            #取消注释
192.168.174.21
192.168.174.22
192.168.174.23
192.168.174.24
192.168.174.25
192.168.100.147

4.建立连接

bash 复制代码
ssh-copy-id -i /root/.ssh/id_rsa.pub root@192.168.174.15
ssh-copy-id -i /root/.ssh/id_rsa.pub root@192.168.100.147

5.测试

相关推荐
orion571 天前
Missing Semester Class1:course overview and introduction of shell
linux
用户120487221611 天前
Linux驱动编译与加载
linux·嵌入式
程序员老赵1 天前
服务器文件不想 SFTP 上传?Docker 跑个 File Browser,浏览器就能管理
服务器·docker·开源
vivo互联网技术1 天前
从 10 分钟到 1 秒:ES 深度分页任意跳页的三轮优化实战
服务器·数据库·redis·elasticsearch·深度分页
用户805533698031 天前
Input 子系统架构:Core、Handler、Driver 三层是怎么协作的
linux·嵌入式
用户805533698031 天前
RK-Forge外设系列开篇 - 把板子从「能启动」变成「能用」:Ethernet/SPI/MMC 三个纯接线外设
linux·github·嵌入式
七歌杜金房2 天前
我终于又有了自己的 Linux 电脑
linux·debian·mac
tntxia3 天前
linux curl命令详解_curl详解
linux
扛枪的书生3 天前
Linux 网络管理器用法速查
linux