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

相关推荐
Wang's Blog1 天前
Linux小课堂: 文件操作警惕高危删除命令与深入文件链接机制
linux·运维·服务器
水月wwww1 天前
操作系统——进程管理
linux·操作系统·vim·进程·进程调度
我科绝伦(Huanhuan Zhou)1 天前
分享一个可以一键制作在线yum源的脚本
linux·运维
Paper_Love1 天前
Linux-查看硬件接口软件占用
linux·运维·服务器
wydaicls1 天前
Linux 系统下 ZONE 区域的划分
linux·运维·服务器
带土11 天前
17. Linux wc命令
linux
螺旋小蜗1 天前
Linux Cgroup与Device Whitelist详解
linux·运维·服务器·cgroup
染指11101 天前
36.渗透-端口
linux·运维·服务器
takashi_void1 天前
如何在本地部署大语言模型(Windows,Mac,Linux)三系统教程
linux·人工智能·windows·macos·语言模型·nlp
EndingCoder1 天前
WebSocket实时通信:Socket.io
服务器·javascript·网络·websocket·网络协议·node.js