我正在" with_items"中启动多个cloudformation堆栈。像这样在ansible循环:
- name: Create CF stack in AWS
cloudformation:
stack_name: "{{ item.name }}"
state: "present"
template: "{{ item.name }}.py.json"
template_parameters: "{{ item.template_parameters }}"
with_items: "{{ CF_TEMPLATE_ITEMS }}"
我可以以某种方式让ansible并行启动这个堆栈吗?
答案 0 :(得分:2)
在启用了fire-and-forget方案中使用异步任务(并等待它们在单独的任务中完成)应该起作用,因为ansible 2.0:
- name: Create CF stack in AWS
async: 100
poll: 0
cloudformation:
stack_name: "{{ item.name }}"
state: "present"
template: "{{ item.name }}.py.json"
template_parameters: "{{ item.template_parameters }}"
with_items: "{{ CF_TEMPLATE_ITEMS }}"
register: cf_stack_async_results
- async_status:
jid: "{{item.ansible_job_id}}"
with_items: cf_stack_async_results.results
register: cf_stack_async_poll_results
until: cf_stack_async_poll_results.finished
retries: 30