如何在Ansible剧本中并行运行两个角色



我需要在Ansible中以并发模式运行一些角色。

我运行ansible通过:

ansible-playbook install_full.yml --tags "10_clean_up,20_pull_images,30_install_postgres_11,40_install_jboss-eap-7.0" --extra-vars "ansible_user=user ansible_password=password"

剧本install_full.yml看起来像:

- hosts: localhost
vars_files:
- "vars/build.yml"
roles:
- { role: 10_clean_up, tags: 10_clean_up }
- { role: 20_pull_images, tags: 20_pull_images }
- { role: 30_install_postgres_11, tags: 30_install_postgres_11 }
- { role: 40_install_jboss-eap-7.0, tags: 40_install_jboss-eap-7.0 }

30和40个角色可以同时运行(以节省一些时间(,是否可以并行运行几个角色,而不是像现在那样按顺序列表?

提前感谢!

目前还不可能,许多人都要求提供该功能。来自可靠项目:https://github.com/ansible/ansible/issues/19083.仅供参考,可以在任务上使用async,但不可能在角色上使用它。

要同时运行的角色集需要strategy: free。看看这个:

https://medium.com/@ibrahimgunduz34/可执行的平行书本-30799ccda4e0

最新更新