一、修改ansible配置文件

1、配置ansible配置文件

inventory      = /etc/ansible/hosts           #定义资源清单inventory文件的位置,一般保持默认
library        = /usr/share/my_modules/   #library指向ansible模块的目录,一般保持默认

forks          = 5                                         #设置多少个进程同时工作

sudo_user      = root                                 #设置默认执行命令的用户,也可在playbook中重新设置此参数

remote_port    = 22                                  #制定连接被管理的管理端口,默认为22
timeout        = 10                                    #设置SSH连接的超时时间间隔,单位为秒

 

2、配置ansible hosts 文件

[root@mongodb05 ansible]# cat hosts
[agent]
172.16.102.11
172.16.102.12
172.16.102.13
172.16.102.14
172.16.102.16
172.16.102.17
172.16.102.18
172.16.102.19
172.16.102.20

 

 3、验证ansible

ansible agent -m command -a "ls /home"

 

 ansible agent -m command -a "ls /home" -vvv  (-vvv 详细输出)

 posted on 2020-01-21 11:11  xibuhaohao  阅读(214)  评论(0编辑  收藏  举报