Add test for meta: end_play (#59118)

- Set ansible_python_interpreter for hosts using local connection
pull/59150/head
Sam Doran 5 years ago committed by GitHub
parent e8a7d89180
commit d17e7a91b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,3 +0,0 @@
[local]
testhost ansible_connection=local host_var_role_name=role3
testhost2 ansible_connection=local host_var_role_name=role2

@ -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 }}"

@ -4,7 +4,7 @@ set -eux
# test end_host meta task, with when conditional # test end_host meta task, with when conditional
for test_strategy in linear free; do 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: end_host conditional evaluated to false, continuing execution for testhost" <<< "$out"
grep -q "META: ending play for testhost2" <<< "$out" grep -q "META: ending play for testhost2" <<< "$out"
@ -14,10 +14,18 @@ done
# test end_host meta task, on all hosts # test end_host meta task, on all hosts
for test_strategy in linear free; do 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 testhost" <<< "$out"
grep -q "META: ending play for testhost2" <<< "$out" grep -q "META: ending play for testhost2" <<< "$out"
grep -qv "play not ended for testhost" <<< "$out" grep -qv "play not ended for testhost" <<< "$out"
grep -qv "play not ended for testhost2" <<< "$out" grep -qv "play not ended for testhost2" <<< "$out"
done 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

@ -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'
Loading…
Cancel
Save