end_play: end the current play only (#76674)

Fixes #76672
pull/76736/head
Martin Krizek 3 years ago committed by GitHub
parent 4a62c4e3e4
commit f78deccec2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
bugfixes:
- Fix ``end_play`` to end the current play only (https://github.com/ansible/ansible/issues/76672)

@ -190,7 +190,6 @@ class PlaybookExecutor:
result = self._tqm.run(play=play)
except AnsibleEndPlay as e:
result = e.result
break_play = True
break
# break the play if the result equals the special return code

@ -55,6 +55,13 @@ for test_strategy in linear free; do
[ "$(grep -c "Testing end_play on host" <<< "$out" )" -eq 1 ]
grep -q "META: ending play" <<< "$out"
grep -qv 'Failed to end using end_play' <<< "$out"
out="$(ansible-playbook test_end_play_multiple_plays.yml -i inventory.yml -e test_strategy=$test_strategy -vv "$@")"
grep -q "META: ending play" <<< "$out"
grep -q "Play 1" <<< "$out"
grep -q "Play 2" <<< "$out"
grep -qv 'Failed to end using end_play' <<< "$out"
done
# test end_batch meta task

@ -0,0 +1,18 @@
- name: Testing end_play with multiple plays with strategy {{ test_strategy | default('linear') }}
hosts: testhost
gather_facts: no
strategy: "{{ test_strategy | default('linear') }}"
tasks:
- debug:
msg: "Play 1"
- meta: end_play
- fail:
msg: 'Failed to end using end_play'
- name: Testing end_play with multiple plays with strategy {{ test_strategy | default('linear') }}
hosts: testhost
gather_facts: no
strategy: "{{ test_strategy | default('linear') }}"
tasks:
- debug:
msg: "Play 2"
Loading…
Cancel
Save