2016-02-03 19:53:47 +00:00
|
|
|
- name: simple block test
|
2019-01-25 03:25:06 +00:00
|
|
|
hosts: testhost
|
2016-02-03 19:53:47 +00:00
|
|
|
gather_facts: yes
|
2016-02-03 23:42:06 +00:00
|
|
|
strategy: "{{test_strategy|default('linear')}}"
|
2016-02-03 19:53:47 +00:00
|
|
|
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
|
2018-01-30 12:16:19 +00:00
|
|
|
nested_block_fail_always: false
|
2016-02-03 19:53:47 +00:00
|
|
|
tasks:
|
|
|
|
- block:
|
|
|
|
- name: set block tasks run flag
|
|
|
|
set_fact:
|
|
|
|
block_tasks_run: true
|
2016-05-27 19:28:13 +00:00
|
|
|
- name: EXPECTED FAILURE fail in tasks
|
2016-02-03 19:53:47 +00:00
|
|
|
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
|
2016-05-27 19:28:13 +00:00
|
|
|
- name: EXPECTED FAILURE fail in rescue
|
2016-02-03 19:53:47 +00:00
|
|
|
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
|
2016-03-09 18:29:22 +00:00
|
|
|
#- 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
|
2016-02-03 19:53:47 +00:00
|
|
|
- meta: clear_host_errors
|
|
|
|
|
2018-01-30 12:16:19 +00:00
|
|
|
# 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
|
|
|
|
|
2018-02-02 15:25:55 +00:00
|
|
|
- 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
|
|
|
|
|
2016-02-03 19:53:47 +00:00
|
|
|
post_tasks:
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- block_tasks_run
|
|
|
|
- block_rescue_run
|
|
|
|
- block_always_run
|
2016-03-09 18:29:22 +00:00
|
|
|
#- nested_block_always_run
|
2016-02-03 19:53:47 +00:00
|
|
|
- not tasks_run_after_failure
|
|
|
|
- not rescue_run_after_failure
|
|
|
|
- not always_run_after_failure
|
2018-01-30 12:16:19 +00:00
|
|
|
- nested_block_fail_always
|
2016-02-03 19:53:47 +00:00
|
|
|
- debug: msg="TEST COMPLETE"
|
|
|
|
|
|
|
|
- name: block with includes
|
2019-01-26 03:37:56 +00:00
|
|
|
hosts: testhost
|
2016-02-03 19:53:47 +00:00
|
|
|
gather_facts: yes
|
2016-02-03 23:42:06 +00:00
|
|
|
strategy: "{{test_strategy|default('linear')}}"
|
2016-02-03 19:53:47 +00:00
|
|
|
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"
|
2016-03-09 18:29:22 +00:00
|
|
|
- name: flag should not be set after failure in rescue
|
2016-02-03 19:53:47 +00:00
|
|
|
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"
|