Skip to content

Instantly share code, notes, and snippets.

@felher
Created July 13, 2023 15:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save felher/8ebb955ac6a630ea5e694ae99b2fec62 to your computer and use it in GitHub Desktop.
Save felher/8ebb955ac6a630ea5e694ae99b2fec62 to your computer and use it in GitHub Desktop.
ansible parallelism
- name: Tests
hosts: study_hosts
gather_facts: false
become: false
tasks:
- name: A
ansible.builtin.command: sleep 1
loop: "{{ [1, 2] }}"
# Runs:
# 1s: wait on host 1 && wait on host 2
# 2s: wait on host 1 && wait on host 2
- name: Tests
hosts: study_hosts
gather_facts: false
become: false
tasks:
- name: A
ansible.builtin.command: sleep 1
loop: "{{ [inventory_hostname, inventory_hostname] }}"
# Runs:
# 1s: wait on host 1 && wait on host 2
# 2s: wait on host 1 && wait on host 2
- name: Tests
hosts: study_hosts
gather_facts: false
become: false
tasks:
- name: A
ansible.builtin.include_role:
name: "test"
loop: "{{ [1, 2] }}"
# Runs:
# 1s: wait on host 1 && wait on host 2
# 2s: wait on host 1 && wait on host 2
- name: Tests
hosts: study_hosts
gather_facts: false
become: false
tasks:
- name: A
ansible.builtin.include_role:
name: "test"
loop: "{{ [inventory_hostname, inventory_hostname] }}"
# Runs:
# 1s: wait on host 1
# 2s: wait on host 1
# 3s: wait on host 2
# 4s: wait on host 2
- name: Wait
ansible.builtin.command: sleep 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment