From a2c620819fb203d295ac5b47b00f344480e322b6 Mon Sep 17 00:00:00 2001 From: Martin Krizek Date: Thu, 13 Feb 2020 21:35:00 +0100 Subject: [PATCH] Remove a host from a play after meta: end_host (#66851) * Remove a host from a play after meta: end_host * Fix changelog --- changelogs/fragments/end_host-remove_host_from_play.yml | 2 ++ lib/ansible/plugins/strategy/__init__.py | 1 + 2 files changed, 3 insertions(+) create mode 100644 changelogs/fragments/end_host-remove_host_from_play.yml diff --git a/changelogs/fragments/end_host-remove_host_from_play.yml b/changelogs/fragments/end_host-remove_host_from_play.yml new file mode 100644 index 00000000000..dc77a0bab03 --- /dev/null +++ b/changelogs/fragments/end_host-remove_host_from_play.yml @@ -0,0 +1,2 @@ +bugfixes: + - "Fix a bug when a host was not removed from a play after ``meta: end_host`` and as a result the host was still present in ``ansible_play_hosts`` and ``ansible_play_batch`` variables." diff --git a/lib/ansible/plugins/strategy/__init__.py b/lib/ansible/plugins/strategy/__init__.py index dc83744a12e..03edd50667c 100644 --- a/lib/ansible/plugins/strategy/__init__.py +++ b/lib/ansible/plugins/strategy/__init__.py @@ -1094,6 +1094,7 @@ class StrategyBase: elif meta_action == 'end_host': if _evaluate_conditional(target_host): iterator._host_states[target_host.name].run_state = iterator.ITERATING_COMPLETE + iterator._play._removed_hosts.append(target_host.name) msg = "ending play for %s" % target_host.name else: skipped = True