blob: 012d5ab2703c417dd0efa917c40eb7ffb5e3ec3d (
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
- name: simple block test
hosts: testhost
gather_facts: yes
strategy: "{{test_strategy|default('linear')}}"
vars:
block_tasks_run: false
block_rescue_run: false
block_always_run: false
nested_block_always_run: false
tasks_run_after_failure: false
rescue_run_after_failure: false
always_run_after_failure: false
nested_block_fail_always: false
tasks:
- block:
- name: set block tasks run flag
set_fact:
block_tasks_run: true
- name: EXPECTED FAILURE fail in tasks
fail:
- name: tasks flag should not be set after failure
set_fact:
tasks_run_after_failure: true
rescue:
- name: set block rescue run flag
set_fact:
block_rescue_run: true
- name: EXPECTED FAILURE fail in rescue
fail:
- name: tasks flag should not be set after failure in rescue
set_fact:
rescue_run_after_failure: true
always:
- name: set block always run flag
set_fact:
block_always_run: true
#- block:
# - meta: noop
# always:
# - name: set nested block always run flag
# set_fact:
# nested_block_always_run: true
# - name: fail in always
# fail:
# - name: tasks flag should not be set after failure in always
# set_fact:
# always_run_after_failure: true
- meta: clear_host_errors
# https://github.com/ansible/ansible/issues/35148
- block:
- block:
- name: EXPECTED FAILURE test triggering always by failing in nested block with run_once set
fail:
run_once: true
always:
- name: set block fail always run flag
set_fact:
nested_block_fail_always: true
- meta: clear_host_errors
- block:
- block:
- name: EXPECTED FAILURE test triggering always by failing in nested block with any_errors_fatal set
fail:
any_errors_fatal: true
always:
- name: set block fail always run flag
set_fact:
nested_block_fail_always: true
- meta: clear_host_errors
post_tasks:
- assert:
that:
- block_tasks_run
- block_rescue_run
- block_always_run
#- nested_block_always_run
- not tasks_run_after_failure
- not rescue_run_after_failure
- not always_run_after_failure
- nested_block_fail_always
- debug: msg="TEST COMPLETE"
- name: block with includes
hosts: testhost
gather_facts: yes
strategy: "{{test_strategy|default('linear')}}"
vars:
rescue_run_after_include_fail: false
always_run_after_include_fail_in_rescue: false
tasks_run_after_failure: false
rescue_run_after_failure: false
always_run_after_failure: false
tasks:
- block:
- name: include fail.yml in tasks
include: fail.yml
args:
msg: "failed from tasks"
- name: tasks flag should not be set after failure
set_fact:
tasks_run_after_failure: true
rescue:
- set_fact:
rescue_run_after_include_fail: true
- name: include fail.yml in rescue
include: fail.yml
args:
msg: "failed from rescue"
- name: flag should not be set after failure in rescue
set_fact:
rescue_run_after_failure: true
always:
- set_fact:
always_run_after_include_fail_in_rescue: true
- meta: clear_host_errors
post_tasks:
- assert:
that:
- rescue_run_after_include_fail
- always_run_after_include_fail_in_rescue
- not tasks_run_after_failure
- not rescue_run_after_failure
- not always_run_after_failure
- debug: msg="TEST COMPLETE"
|