Dear Tech Team,
I'm Guannan from China. I'm new to Ansible and looking for some technical help.
Actually I'm looking for a method to execute one role in parallel with loops of different configuration files. For example, I want to create 100 sites using role "create_site" with 100 different configuration files. I simply write a playbook like this:
- hosts: localhost
gather_facts: no
tasks:
- name: register files
shell: "find /tmp/site_files -name '*.yml' | sort"
register: file_names
- include_role:
name: create_site
vars_from: "{{ item }}"
with_items: "{{ file_names.stdout_lines }}"
This will create 100 sites in serial. If create one site take 2 minutes, then the whole playbook will take over 200 minutes. I found 'async' option when execute tasks, however it seems only used for async jobs on different hosts. Do you guys have experience or methods on how to execute one role with different configuration files in parallel? Please send me E-mails.
Much thanks for your help!