summaryrefslogtreecommitdiff
path: root/lib/ansible/plugins/strategy/free.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ansible/plugins/strategy/free.py')
-rw-r--r--lib/ansible/plugins/strategy/free.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/ansible/plugins/strategy/free.py b/lib/ansible/plugins/strategy/free.py
index 6f45114b..82a21b1c 100644
--- a/lib/ansible/plugins/strategy/free.py
+++ b/lib/ansible/plugins/strategy/free.py
@@ -40,7 +40,7 @@ from ansible.playbook.included_file import IncludedFile
from ansible.plugins.loader import action_loader
from ansible.plugins.strategy import StrategyBase
from ansible.template import Templar
-from ansible.module_utils._text import to_text
+from ansible.module_utils.common.text.converters import to_text
from ansible.utils.display import Display
display = Display()
@@ -146,6 +146,8 @@ class StrategyModule(StrategyBase):
# advance the host, mark the host blocked, and queue it
self._blocked_hosts[host_name] = True
iterator.set_state_for_host(host.name, state)
+ if isinstance(task, Handler):
+ task.remove_host(host)
try:
action = action_loader.get(task.action, class_only=True, collection_list=task.collections)
@@ -173,10 +175,9 @@ class StrategyModule(StrategyBase):
# check to see if this task should be skipped, due to it being a member of a
# role which has already run (and whether that role allows duplicate execution)
- if not isinstance(task, Handler) and task._role and task._role.has_run(host):
- # If there is no metadata, the default behavior is to not allow duplicates,
- # if there is metadata, check to see if the allow_duplicates flag was set to true
- if task._role._metadata is None or task._role._metadata and not task._role._metadata.allow_duplicates:
+ if not isinstance(task, Handler) and task._role:
+ role_obj = self._get_cached_role(task, iterator._play)
+ if role_obj.has_run(host) and role_obj._metadata.allow_duplicates is False:
display.debug("'%s' skipped because role has already run" % task, host=host_name)
del self._blocked_hosts[host_name]
continue