summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Krizek <martin.krizek@gmail.com>2022-01-11 16:27:42 +0100
committerGitHub <noreply@github.com>2022-01-11 16:27:42 +0100
commitf78deccec2d4b5447f32d4fc67eaa549f479ccaa (patch)
tree8487350f51bcd43ec92ea57133d070eec26a4b0c
parentapt: add support for package version >= (#75002) (diff)
downloadansible-f78deccec2d4b5447f32d4fc67eaa549f479ccaa.tar.xz
ansible-f78deccec2d4b5447f32d4fc67eaa549f479ccaa.zip
end_play: end the current play only (#76674)
Fixes #76672
-rw-r--r--changelogs/fragments/76672-fix-end_play-multiple_plays.yml2
-rw-r--r--lib/ansible/executor/playbook_executor.py1
-rwxr-xr-xtest/integration/targets/meta_tasks/runme.sh7
-rw-r--r--test/integration/targets/meta_tasks/test_end_play_multiple_plays.yml18
4 files changed, 27 insertions, 1 deletions
diff --git a/changelogs/fragments/76672-fix-end_play-multiple_plays.yml b/changelogs/fragments/76672-fix-end_play-multiple_plays.yml
new file mode 100644
index 0000000000..30766d0e44
--- /dev/null
+++ b/changelogs/fragments/76672-fix-end_play-multiple_plays.yml
@@ -0,0 +1,2 @@
+bugfixes:
+ - Fix ``end_play`` to end the current play only (https://github.com/ansible/ansible/issues/76672)
diff --git a/lib/ansible/executor/playbook_executor.py b/lib/ansible/executor/playbook_executor.py
index e0d3a645aa..e8b2a3dc25 100644
--- a/lib/ansible/executor/playbook_executor.py
+++ b/lib/ansible/executor/playbook_executor.py
@@ -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
diff --git a/test/integration/targets/meta_tasks/runme.sh b/test/integration/targets/meta_tasks/runme.sh
index f5916ec762..c29579bf1d 100755
--- a/test/integration/targets/meta_tasks/runme.sh
+++ b/test/integration/targets/meta_tasks/runme.sh
@@ -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
diff --git a/test/integration/targets/meta_tasks/test_end_play_multiple_plays.yml b/test/integration/targets/meta_tasks/test_end_play_multiple_plays.yml
new file mode 100644
index 0000000000..2cc8d1e660
--- /dev/null
+++ b/test/integration/targets/meta_tasks/test_end_play_multiple_plays.yml
@@ -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"