Skip to content

Instantly share code, notes, and snippets.

@goneri
Created January 10, 2020 19:31
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 goneri/b5c3a9b30e4768c6859303778ca86402 to your computer and use it in GitHub Desktop.
Save goneri/b5c3a9b30e4768c6859303778ca86402 to your computer and use it in GitHub Desktop.
split-up ansible-test role list
- hosts: localhost
vars:
split_in: 4
do_number: 1 # 1 to 4
tasks:
- command: 'ansible-test integration --python 3.7 -vvv --list-targets zuul/vmware/vcenter_1esxi/'
register: ansible_test_targets
- set_fact:
number_entries: "{{ ansible_test_targets.stdout_lines|length }}"
- set_fact:
start_at: "{{ number_entries|int // split_in * (do_number -1)|int }}"
end_at: "{{ (number_entries|int // split_in * (do_number |int)) }}"
- debug:
msg: "Do roles: {{ ansible_test_targets.stdout_lines[start_at|int:end_at|int] }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment