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