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

相关推荐
sulikey1 小时前
Linux ext2文件系统结构
linux·操作系统·文件系统·linux文件系统·ext2·ext2文件系统
白菜欣2 小时前
Linux — 进程控制
android·linux·运维
皮卡狮2 小时前
Linux开发专属工具
linux
weixin_421725262 小时前
Linux 编程语言全解析:C、C++、Python、Go、Rust 谁更强?
linux·python·go·c·编程语言
Tolalal3 小时前
Vmware Ubuntu虚拟机扩容
linux·运维·ubuntu
我星期八休息3 小时前
Linux系统编程—基础IO
linux·运维·服务器·c语言·c++·人工智能·算法
Shingmc33 小时前
【Linux】数据链路层
linux·服务器·网络
a752066284 小时前
零基础实操:小龙虾 AI OpenClaw 接入 Kimi 详细步骤
运维·服务器
KK溜了溜了4 小时前
Python从入门到精通
服务器·开发语言·python
bksczm4 小时前
文件描述符
linux