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.测试

相关推荐
cui_win1 小时前
【内存】Linux 内核优化实战 - net.ipv4.tcp_tw_reuse
linux·网络·tcp/ip
BD_Marathon3 小时前
Ubuntu:Mysql服务器
服务器·mysql·ubuntu
CodeWithMe4 小时前
【Note】《深入理解Linux内核》 Chapter 15 :深入理解 Linux 页缓存
linux·spring·缓存
0wioiw04 小时前
Ubuntu基础(监控重启和查找程序)
linux·服务器·ubuntu
Tipriest_4 小时前
Ubuntu常用的软件格式deb, rpm, dmg, AppImage等打包及使用方法
linux·运维·ubuntu
艾希逐月4 小时前
TCP数据的发送和接收
服务器·网络·tcp/ip
胡斌附体5 小时前
linux测试端口是否可被外部访问
linux·运维·服务器·python·测试·端口测试·临时服务器
愚润求学5 小时前
【Linux】自旋锁和读写锁
linux·运维
大锦终5 小时前
【Linux】常用基本指令
linux·运维·服务器·centos
IT项目管理5 小时前
达梦数据库DMHS介绍及安装部署
linux·数据库