ansible 安装和测试
一、环境准备
[root@master ~]# cat /etc/redhat-release
二、安装Ansible
- 更改yum 源:
[root@master ~]#wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
2.软件包安装
EPEL 已经提供了ansible 所需的所有支持软件包,所以在这里使用epel 源进行安装:
3.安装Ansible
[root@master ~]# yum install ansible -y
4.免密要认证
ansible 默认提供了很多模块来供我们使用。在 Linux 中,我们可以通过 ansible-doc -l 命令查看到当前 ansible 都支持哪些模块,通过 ansible-doc -s 模块名 又可以查看该模块有哪些参数可以使用。
5.建立host文件
Ansible 的host文件默认在/etc/ansible/ 这个目录下面,采用rpm安装的ansible会将该host文件作为范例,其中提示ansible是支持域名和IP的两种客户端命名格式的,进过测试时没有问题的,还支持不同的安装分组方法,建议好好看看,这里提供三台机器,分为master client01 client02 将他们分为两组 master 和slave
6.测试ansible 的使用
在这里使用ping模块:
解读:从返回值分析,ansiable salve 接待你10.0.0.20,10.0.0.21 的ping
值成功。说明ansiable 已经能够使用。
7.验证是否支持域名解析测试:
[root@master ~]# ansible slave -i /etc/ansible/hosts -m ping
验证是支持服务器本地域名解析的

浙公网安备 33010602011771号