如何在 Ansible 剧本中并行运行几个角色? [英] How to run couple of roles in parallel in Ansible playbook?
问题描述
我需要在 Ansible 中以并发模式运行一些角色.
I need to run some roles in concurrent mode in Ansible.
我通过以下方式运行 ansible:
I run ansible via:
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 看起来像:
The playbook install_full.yml looks like:
- 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 角色可以同时运行(以节省一些时间),是否可以并行运行几个角色,不像现在 - 按顺序列表?
30 and 40 role can be run in the same time (to save some time), is it possible to run couple of roles in parallel, not like now - by order list ?
提前致谢!
推荐答案
目前无法实现,许多人要求使用该功能.来自 ansible 项目:https://github.com/ansible/ansible/issues/19083一>.仅供参考,可以在任务上使用异步,但不能在角色上使用.
It is not possible at this time and many have asked for that feature. From the ansible project : https://github.com/ansible/ansible/issues/19083. FYI it is possible to use async on tasks, but it is not possible to use it on roles.
这篇关于如何在 Ansible 剧本中并行运行几个角色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!