From d17e7a91b1a683f4fb6eeefeadf8636bdc0a8544 Mon Sep 17 00:00:00 2001 From: Sam Doran Date: Tue, 16 Jul 2019 12:41:48 -0400 Subject: [PATCH] Add test for meta: end_play (#59118) - Set ansible_python_interpreter for hosts using local connection --- test/integration/targets/meta_tasks/inventory | 3 --- test/integration/targets/meta_tasks/inventory.yml | 9 +++++++++ test/integration/targets/meta_tasks/runme.sh | 12 ++++++++++-- .../integration/targets/meta_tasks/test_end_play.yml | 12 ++++++++++++ 4 files changed, 31 insertions(+), 5 deletions(-) delete mode 100644 test/integration/targets/meta_tasks/inventory create mode 100644 test/integration/targets/meta_tasks/inventory.yml create mode 100644 test/integration/targets/meta_tasks/test_end_play.yml diff --git a/test/integration/targets/meta_tasks/inventory b/test/integration/targets/meta_tasks/inventory deleted file mode 100644 index 470333e7bac..00000000000 --- 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 00000000000..5fb39e5fb88 --- /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 c9ddbfeb538..b617965df45 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 00000000000..29489dc439b --- /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'