1.制作清单模板
[root@afei weixin]# tree
.
├── files
│ └── httpd.conf
├── group_vars
│ └── wbservers
├── host_vars
│ └── 192.168.240.134
├── inventory
├── password
└── playbook.yml
2.使用forks在ansible中配置并行
[root@afei weixin]# vim /etc/ansible/ansible.cfg
#inventory = /etc/ansible/hosts
inventory = /etc/ansible/inventory
#library = /usr/share/my_modules/
#module_utils = /usr/share/my_module_utils/
#remote_tmp = ~/.ansible/tmp
#local_tmp = ~/.ansible/tmp
#plugin_filters_cfg = /etc/ansible/plugin_filters.yml
#forks = 5
#poll_interval = 15
#sudo_user = root
#ask_sudo_pass = True
#ask_pass = True
#transport = smart
#remote_port = 22
#module_lang = C
#module_set_locale = False
注:forks默认参数为5,同时控制5台主机
3.查看配置文件中forks参数
[root@afei weixin]# ansible-config dump|grep -i fork
DEFAULT_FORKS(default) =