Track role execution per-host, not overall in the role
Fixes #11863 Fixes #11878
This commit is contained in:
parent
fb5003dbfc
commit
adb9d7e461
5 changed files with 14 additions and 20 deletions
|
@ -162,8 +162,8 @@ class PlayIterator:
|
||||||
|
|
||||||
if task and task._role:
|
if task and task._role:
|
||||||
# if we had a current role, mark that role as completed
|
# if we had a current role, mark that role as completed
|
||||||
if s.cur_role and task._role != s.cur_role and s.cur_role._had_task_run and not peek:
|
if s.cur_role and task._role != s.cur_role and host.name in s.cur_role._had_task_run and not peek:
|
||||||
s.cur_role._completed = True
|
s.cur_role._completed[host.name] = True
|
||||||
s.cur_role = task._role
|
s.cur_role = task._role
|
||||||
|
|
||||||
if not peek:
|
if not peek:
|
||||||
|
|
|
@ -80,8 +80,8 @@ class Role(Base, Become, Conditional, Taggable):
|
||||||
self._handler_blocks = []
|
self._handler_blocks = []
|
||||||
self._default_vars = dict()
|
self._default_vars = dict()
|
||||||
self._role_vars = dict()
|
self._role_vars = dict()
|
||||||
self._had_task_run = False
|
self._had_task_run = dict()
|
||||||
self._completed = False
|
self._completed = dict()
|
||||||
|
|
||||||
super(Role, self).__init__()
|
super(Role, self).__init__()
|
||||||
|
|
||||||
|
@ -303,13 +303,13 @@ class Role(Base, Become, Conditional, Taggable):
|
||||||
block_list.extend(self._handler_blocks)
|
block_list.extend(self._handler_blocks)
|
||||||
return block_list
|
return block_list
|
||||||
|
|
||||||
def has_run(self):
|
def has_run(self, host):
|
||||||
'''
|
'''
|
||||||
Returns true if this role has been iterated over completely and
|
Returns true if this role has been iterated over completely and
|
||||||
at least one task was run
|
at least one task was run
|
||||||
'''
|
'''
|
||||||
|
|
||||||
return self._had_task_run and self._completed and not self._metadata.allow_duplicates
|
return host.name in self._completed and not self._metadata.allow_duplicates
|
||||||
|
|
||||||
def compile(self, play, dep_chain=[]):
|
def compile(self, play, dep_chain=[]):
|
||||||
'''
|
'''
|
||||||
|
@ -348,8 +348,8 @@ class Role(Base, Become, Conditional, Taggable):
|
||||||
res['_role_vars'] = self._role_vars
|
res['_role_vars'] = self._role_vars
|
||||||
res['_role_params'] = self._role_params
|
res['_role_params'] = self._role_params
|
||||||
res['_default_vars'] = self._default_vars
|
res['_default_vars'] = self._default_vars
|
||||||
res['_had_task_run'] = self._had_task_run
|
res['_had_task_run'] = self._had_task_run.copy()
|
||||||
res['_completed'] = self._completed
|
res['_completed'] = self._completed.copy()
|
||||||
|
|
||||||
if self._metadata:
|
if self._metadata:
|
||||||
res['_metadata'] = self._metadata.serialize()
|
res['_metadata'] = self._metadata.serialize()
|
||||||
|
@ -373,8 +373,8 @@ class Role(Base, Become, Conditional, Taggable):
|
||||||
self._role_vars = data.get('_role_vars', dict())
|
self._role_vars = data.get('_role_vars', dict())
|
||||||
self._role_params = data.get('_role_params', dict())
|
self._role_params = data.get('_role_params', dict())
|
||||||
self._default_vars = data.get('_default_vars', dict())
|
self._default_vars = data.get('_default_vars', dict())
|
||||||
self._had_task_run = data.get('_had_task_run', False)
|
self._had_task_run = data.get('_had_task_run', dict())
|
||||||
self._completed = data.get('_completed', False)
|
self._completed = data.get('_completed', dict())
|
||||||
|
|
||||||
if include_deps:
|
if include_deps:
|
||||||
deps = []
|
deps = []
|
||||||
|
|
|
@ -205,14 +205,8 @@ class StrategyBase:
|
||||||
# lookup the role in the ROLE_CACHE to make sure we're dealing
|
# lookup the role in the ROLE_CACHE to make sure we're dealing
|
||||||
# with the correct object and mark it as executed
|
# with the correct object and mark it as executed
|
||||||
for (entry, role_obj) in iterator._play.ROLE_CACHE[task_result._task._role._role_name].iteritems():
|
for (entry, role_obj) in iterator._play.ROLE_CACHE[task_result._task._role._role_name].iteritems():
|
||||||
params = task_result._task._role._role_params
|
if role_obj._uuid == task_result._task._role._uuid:
|
||||||
if task_result._task._role.tags is not None:
|
role_obj._had_task_run[host.name] = True
|
||||||
params['tags'] = task_result._task._role.tags
|
|
||||||
if task_result._task._role.when is not None:
|
|
||||||
params['when'] = task_result._task._role.when
|
|
||||||
hashed_entry = hash_params(params)
|
|
||||||
if entry == hashed_entry:
|
|
||||||
role_obj._had_task_run = True
|
|
||||||
|
|
||||||
ret_results.append(task_result)
|
ret_results.append(task_result)
|
||||||
|
|
||||||
|
|
|
@ -97,7 +97,7 @@ class StrategyModule(StrategyBase):
|
||||||
|
|
||||||
# check to see if this task should be skipped, due to it being a member of a
|
# 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)
|
# role which has already run (and whether that role allows duplicate execution)
|
||||||
if task._role and task._role.has_run():
|
if task._role and task._role.has_run(host):
|
||||||
# If there is no metadata, the default behavior is to not allow duplicates,
|
# 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 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 task._role._metadata is None or task._role._metadata and not task._role._metadata.allow_duplicates:
|
||||||
|
|
|
@ -170,7 +170,7 @@ class StrategyModule(StrategyBase):
|
||||||
|
|
||||||
# check to see if this task should be skipped, due to it being a member of a
|
# 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)
|
# role which has already run (and whether that role allows duplicate execution)
|
||||||
if task._role and task._role.has_run():
|
if task._role and task._role.has_run(host):
|
||||||
# If there is no metadata, the default behavior is to not allow duplicates,
|
# 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 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 task._role._metadata is None or task._role._metadata and not task._role._metadata.allow_duplicates:
|
||||||
|
|
Loading…
Add table
Reference in a new issue