Add test for meta: end_play (#59118)
- Set ansible_python_interpreter for hosts using local connection
This commit is contained in:
parent
e8a7d89180
commit
d17e7a91b1
4 changed files with 31 additions and 5 deletions
|
@ -1,3 +0,0 @@
|
||||||
[local]
|
|
||||||
testhost ansible_connection=local host_var_role_name=role3
|
|
||||||
testhost2 ansible_connection=local host_var_role_name=role2
|
|
9
test/integration/targets/meta_tasks/inventory.yml
Normal file
9
test/integration/targets/meta_tasks/inventory.yml
Normal file
|
@ -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
|
||||||
|
|
12
test/integration/targets/meta_tasks/test_end_play.yml
Normal file
12
test/integration/targets/meta_tasks/test_end_play.yml
Normal file
|
@ -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…
Reference in a new issue