管理端装ansible软件
[root@docker ~]# yum install ansible -y
[root@docker ~]# rpm -qa ansible
ansible-2.9.10-1.el7.noarch
被管理端安装libselinux-python支持库
[root@tomcat001 ~]# yum install libselinux-python -y
[root@tomcat001 ~]# rpm -qa libselinux-python
libselinux-python-2.5-15.el7.x86_64
[root@tomcat002 ~]# yum install libselinux-python -y
[root@tomcat002 ~]# rpm -qa libselinux-python
libselinux-python-2.5-15.el7.x86_64
# 一般在安装系统时,此软件已默认安装。
管理端添加主机信息使用ansible批量管理
说明:将需要管理的主机通过添加组的方式进行批量管理
[tomcat-jar]
192.9.200.227
192.9.200.228
使用ansible批量管理主机测试
[root@docker ~]# ansible tomcat-jar -m command -a "hostname"
[WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details
192.9.200.227 | CHANGED | rc=0 >>
tomcat001
192.9.200.228 | CHANGED | rc=0 >>
tomcat002
至此,ansible软件安装成功。