1--- 2- name: Integration tests for #28231 3 hosts: localhost 4 gather_facts: false 5 tasks: 6 - name: Add some test hosts 7 add_host: 8 name: "foo{{item}}" 9 groups: foo 10 ansible_connection: local 11 ansible_python_interpreter: "{{ ansible_playbook_python }}" 12 loop: "{{ range(10)|list }}" 13 14 # We expect all of the next 3 runs to succeeed 15 # this is done multiple times to increase randomness 16 - assert: 17 that: 18 - item in ansible_delegated_vars 19 delegate_to: "{{ item }}" 20 loop: 21 - "{{ groups.foo|random }}" 22 ignore_errors: true 23 register: result1 24 25 - assert: 26 that: 27 - item in ansible_delegated_vars 28 delegate_to: "{{ item }}" 29 loop: 30 - "{{ groups.foo|random }}" 31 ignore_errors: true 32 register: result2 33 34 - assert: 35 that: 36 - item in ansible_delegated_vars 37 delegate_to: "{{ item }}" 38 loop: 39 - "{{ groups.foo|random }}" 40 ignore_errors: true 41 register: result3 42 43 - debug: 44 var: result1 45 46 - debug: 47 var: result2 48 49 - debug: 50 var: result3 51 52 - name: Ensure all of the 3 asserts were successful 53 assert: 54 that: 55 - results is all 56 vars: 57 results: 58 - "{{ (result1.results|first) is successful }}" 59 - "{{ (result2.results|first) is successful }}" 60 - "{{ (result3.results|first) is successful }}" 61 62 - name: Set delegate 63 set_fact: 64 _delegate: '{{ groups.foo[0] }}' 65 66 - command: "true" 67 delegate_to: "{{ _delegate }}" 68 register: result 69 70 - assert: 71 that: 72 - result.stdout is defined 73 - result.results is undefined 74