diff options
author | Sam Doran <sdoran@redhat.com> | 2019-07-16 12:41:48 -0400 |
---|---|---|
committer | Toshio Kuratomi <a.badger@gmail.com> | 2019-07-17 15:32:26 -0700 |
commit | f837444a7702c5534205b6f6d57d620ad76e37a6 (patch) | |
tree | a48647a4d018313dade19a2cc9b19afa77a8c8bc | |
parent | 0d86a4dbaa0a39299f77228146819d5bed1dc09c (diff) | |
download | ansible-f837444a7702c5534205b6f6d57d620ad76e37a6.tar.gz |
[stable-2.8] Add test for meta: end_play (#59118)
- Set ansible_python_interpreter for hosts using local connection
(cherry picked from commit d17e7a91b1)
Co-authored-by: Sam Doran <sdoran@redhat.com>
-rw-r--r-- | test/integration/targets/meta_tasks/inventory | 3 | ||||
-rw-r--r-- | test/integration/targets/meta_tasks/inventory.yml | 9 | ||||
-rwxr-xr-x | test/integration/targets/meta_tasks/runme.sh | 12 | ||||
-rw-r--r-- | test/integration/targets/meta_tasks/test_end_play.yml | 12 |
4 files changed, 31 insertions, 5 deletions
diff --git a/test/integration/targets/meta_tasks/inventory b/test/integration/targets/meta_tasks/inventory deleted file mode 100644 index 470333e7ba..0000000000 --- a/test/integration/targets/meta_tasks/inventory +++ /dev/null @@ -1,3 +0,0 @@ -[local] -testhost ansible_connection=local host_var_role_name=role3 -testhost2 ansible_connection=local host_var_role_name=role2 diff --git a/test/integration/targets/meta_tasks/inventory.yml b/test/integration/targets/meta_tasks/inventory.yml new file mode 100644 index 0000000000..5fb39e5fb8 --- /dev/null +++ b/test/integration/targets/meta_tasks/inventory.yml @@ -0,0 +1,9 @@ +local: + hosts: + testhost: + host_var_role_name: role3 + testhost2: + host_var_role_name: role2 + vars: + ansible_connection: local + ansible_python_interpreter: "{{ ansible_playbook_python }}" diff --git a/test/integration/targets/meta_tasks/runme.sh b/test/integration/targets/meta_tasks/runme.sh index c9ddbfeb53..b617965df4 100755 --- a/test/integration/targets/meta_tasks/runme.sh +++ b/test/integration/targets/meta_tasks/runme.sh @@ -4,7 +4,7 @@ set -eux # test end_host meta task, with when conditional for test_strategy in linear free; do - out="$(ansible-playbook test_end_host.yml -i inventory -e test_strategy=$test_strategy -vv "$@")" + out="$(ansible-playbook test_end_host.yml -i inventory.yml -e test_strategy=$test_strategy -vv "$@")" grep -q "META: end_host conditional evaluated to false, continuing execution for testhost" <<< "$out" grep -q "META: ending play for testhost2" <<< "$out" @@ -14,10 +14,18 @@ done # test end_host meta task, on all hosts for test_strategy in linear free; do - out="$(ansible-playbook test_end_host_all.yml -i inventory -e test_strategy=$test_strategy -vv "$@")" + out="$(ansible-playbook test_end_host_all.yml -i inventory.yml -e test_strategy=$test_strategy -vv "$@")" grep -q "META: ending play for testhost" <<< "$out" grep -q "META: ending play for testhost2" <<< "$out" grep -qv "play not ended for testhost" <<< "$out" grep -qv "play not ended for testhost2" <<< "$out" done + +# test end_play meta task +for test_strategy in linear free; do + out="$(ansible-playbook test_end_play.yml -i inventory.yml -e test_strategy=$test_strategy -vv "$@")" + + grep -q "META: ending play" <<< "$out" + grep -qv 'Failed to end using end_play' <<< "$out" +done diff --git a/test/integration/targets/meta_tasks/test_end_play.yml b/test/integration/targets/meta_tasks/test_end_play.yml new file mode 100644 index 0000000000..29489dc439 --- /dev/null +++ b/test/integration/targets/meta_tasks/test_end_play.yml @@ -0,0 +1,12 @@ +- name: Testing end_play with strategy {{ test_strategy | default('linear') }} + hosts: testhost:testhost2 + gather_facts: no + strategy: "{{ test_strategy | default('linear') }}" + tasks: + - debug: + msg: "Testing end_play on host {{ inventory_hostname }}" + + - meta: end_play + + - fail: + msg: 'Failed to end using end_play' |