ansible自动化运维实战--服务端安装、环境配置与测试(1)

文章目录

一、准备5台虚拟机

本文使用的系统是centos9,5台机子的IP规划以及主机名如下:

主机名 IP
ansible 192.168.162.101
host01 192.168.162.102
host02 192.168.162.103
host03 192.168.162.104
host04 192.168.162.105

使用xshell连接工具,连接5台服务器

修改ansible服务器,ip为101机子的hosts:

bash 复制代码
vim /etc/hosts
bash 复制代码
192.168.162.101 ansible
192.168.162.102 host01
192.168.162.103 host02
192.168.162.104 host03
192.168.162.105 host04 

保证主机名域名的联通

二、ansible服务端安装

2.1、epel-release安装与配置

EPEL-release(Extra Packages for Enterprise Linux)是一个软件仓库,它为企业级Linux发行版(如CentOS、RHEL等)提供额外的软件包,ansible服务器安装需要安装epel源,它是ansible服务组件的源地址。

bash 复制代码
yum install -y epel-release

2.2、查询ansible源信息

查询一下关于ansible源的信息

bash 复制代码
yum list | grep ansible

2.3、安装ansible

安装ansible到服务器,使其成为一台ansible自动化运维服务器。

bash 复制代码
yum install -y ansible

至此ansible安装完成!!!将来通过这个ansible服务器可以发送指令/shell到目标服务器来批量完成运维工作。

2.4、检查ansible安装状态和命令

查看ansible相关的安装文件列表:

bash 复制代码
rpm -ql ansible
bash 复制代码
ls /etc/ansible/

查看ansible配置文件,hosts文件和角色列表。

通过下列命令可以查看ansible的一些命令:

bash 复制代码
ansible --help

查看ansible支持文档命令:

bash 复制代码
ansible-doc -l

ansible支持的功能模块,查看命令:

bash 复制代码
ansible-doc -s yum

‌"燃烧智慧,编织代码,天才程序员们正蓄势待发。"‌


相关推荐
czhc1140075663几秒前
Linux 76 rsync
linux·运维·python
你不知道我是谁?1 小时前
负载均衡--四层、七层负载均衡的区别
运维·服务器·负载均衡
dyj0951 小时前
【Rancher Server + Kubernets】- Nginx-ingress日志持久化至宿主机
运维·nginx·rancher
码出钞能力3 小时前
linux内核模块的查看
linux·运维·服务器
星辰云-3 小时前
# Linux Centos系统硬盘分区扩容
linux·运维·centos·磁盘扩容
Hellc0073 小时前
Nginx 高级 CC 与 DDoS 防御策略指南
运维·nginx·ddos
feilieren4 小时前
Docker 安装 Elasticsearch 9
运维·elasticsearch·docker·es
小皮侠5 小时前
nginx的使用
java·运维·服务器·前端·git·nginx·github
Maki Winster5 小时前
在 Ubuntu 下配置 oh-my-posh —— 普通用户 + root 各自使用独立主题(共享可执行)
linux·运维·ubuntu
翻滚吧键盘6 小时前
debian及衍生发行版apt包管理常见操作
运维·debian