mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Tweak the way chained callbacks work
This commit is contained in:
parent
dd6399b5ae
commit
3a2df329af
1 changed files with 20 additions and 14 deletions
|
@ -435,7 +435,6 @@ class Runner(object):
|
||||||
# will be unneccessary as it can decide to daisychain via it's own module returns.
|
# will be unneccessary as it can decide to daisychain via it's own module returns.
|
||||||
# and this function can be deleted.
|
# and this function can be deleted.
|
||||||
|
|
||||||
options = utils.parse_kv(self.module_args)
|
|
||||||
return self._execute_module(conn, tmp, 'assemble', self.module_args, inject=inject).daisychain('file')
|
return self._execute_module(conn, tmp, 'assemble', self.module_args, inject=inject).daisychain('file')
|
||||||
|
|
||||||
# *****************************************************
|
# *****************************************************
|
||||||
|
@ -516,7 +515,7 @@ class Runner(object):
|
||||||
|
|
||||||
# *****************************************************
|
# *****************************************************
|
||||||
|
|
||||||
def _executor_internal_inner(self, host, inject, port):
|
def _executor_internal_inner(self, host, inject, port, is_chained=False):
|
||||||
''' decides how to invoke a module '''
|
''' decides how to invoke a module '''
|
||||||
|
|
||||||
# special non-user/non-fact variables:
|
# special non-user/non-fact variables:
|
||||||
|
@ -564,19 +563,24 @@ class Runner(object):
|
||||||
else:
|
else:
|
||||||
result = self._execute_async_module(conn, tmp, module_name, inject=inject)
|
result = self._execute_async_module(conn, tmp, module_name, inject=inject)
|
||||||
|
|
||||||
chained = False
|
result.result['module'] = self.module_name
|
||||||
if result.is_successful() and 'daisychain' in result.result:
|
if result.is_successful() and 'daisychain' in result.result:
|
||||||
chained = True
|
|
||||||
self.module_name = result.result['daisychain']
|
self.module_name = result.result['daisychain']
|
||||||
if 'daisychain_args' in result.result:
|
if 'daisychain_args' in result.result:
|
||||||
self.module_args = result.result['daisychain_args']
|
self.module_args = result.result['daisychain_args']
|
||||||
result2 = self._executor_internal_inner(host, inject, port)
|
result2 = self._executor_internal_inner(host, inject, port, is_chained=True)
|
||||||
|
result2.result['module'] = self.module_name
|
||||||
changed = False
|
changed = False
|
||||||
|
# print "result1=%s" % result.result
|
||||||
|
# print "result2=%s" % result2.result
|
||||||
if result.result.get('changed',False) or result2.result.get('changed',False):
|
if result.result.get('changed',False) or result2.result.get('changed',False):
|
||||||
changed = True
|
changed = True
|
||||||
result.result.update(result2.result)
|
# print "DEBUG=%s" % changed
|
||||||
result.result['changed'] = changed
|
result2.result.update(result.result)
|
||||||
|
result2.result['changed'] = changed
|
||||||
|
result = result2
|
||||||
del result.result['daisychain']
|
del result.result['daisychain']
|
||||||
|
# print "DEBUG2=%s" % result.result['changed']
|
||||||
|
|
||||||
self._delete_remote_files(conn, tmp)
|
self._delete_remote_files(conn, tmp)
|
||||||
conn.close()
|
conn.close()
|
||||||
|
@ -588,13 +592,15 @@ class Runner(object):
|
||||||
data = result.result
|
data = result.result
|
||||||
if 'item' in inject:
|
if 'item' in inject:
|
||||||
result.result['item'] = inject['item']
|
result.result['item'] = inject['item']
|
||||||
if not chained:
|
if is_chained:
|
||||||
if 'skipped' in data:
|
# no callbacks
|
||||||
self.callbacks.on_skipped(result.host)
|
return result
|
||||||
elif not result.is_successful():
|
if 'skipped' in data:
|
||||||
self.callbacks.on_failed(result.host, data)
|
self.callbacks.on_skipped(result.host)
|
||||||
else:
|
elif not result.is_successful():
|
||||||
self.callbacks.on_ok(result.host, data)
|
self.callbacks.on_failed(result.host, data)
|
||||||
|
else:
|
||||||
|
self.callbacks.on_ok(result.host, data)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
# *****************************************************
|
# *****************************************************
|
||||||
|
|
Loading…
Reference in a new issue