【问题标题】:How to run couple of roles in parallel in Ansible playbook?如何在 Ansible 剧本中并行运行几个角色?
【发布时间】:2020-04-08 22:24:41
【问题描述】:

我需要在 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 角色可以同时运行(以节省一些时间),是否可以并行运行几个角色,而不是像现在一样 - 按订单列表?

提前感谢!

【问题讨论】:

    标签: parallel-processing ansible


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

      您需要strategy: free 才能同时运行一组角色。看看这个:

      https://medium.com/@ibrahimgunduz34/parallel-playbook-execution-in-ansible-30799ccda4e0

      【讨论】:

      • 这是不正确的,免费的策略是告诉多个节点它们可以独立运行。每个节点都可以完成其分配的步骤并“尽可能快地运行直到游戏结束:” - 这无助于在单个节点上并行运行角色。见docs.ansible.com/ansible/latest/user_guide/…
      猜你喜欢
      • 2021-11-09
      • 1970-01-01
      • 2015-11-13
      • 1970-01-01
      • 1970-01-01
      • 2015-07-31
      • 2020-08-15
      • 2021-11-01
      • 1970-01-01
      相关资源
      最近更新 更多