mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-23 19:01:26 -07:00
Move delegate_to out of runner module_vars to prevent bleeding across runs
Previously, the delegate_to value was stored in the module_vars of runner, which could lead to bleeding that value across runs and incorrect hosts being delegated to. This patch moves the value to a local variable in the Runner class with some related refactoring of _compute_delegate() in Runner (since the value is no longer required to be a parameter). Fixes #8705
This commit is contained in:
parent
5ec8c28d2a
commit
c3612e08f9
2 changed files with 27 additions and 38 deletions
|
@ -450,9 +450,8 @@ class PlaybookRunnerCallbacks(DefaultRunnerCallbacks):
|
|||
self._async_notified = {}
|
||||
|
||||
def on_unreachable(self, host, results):
|
||||
delegate_to = self.runner.module_vars.get('delegate_to')
|
||||
if delegate_to:
|
||||
host = '%s -> %s' % (host, delegate_to)
|
||||
if self.runner.delegate_to:
|
||||
host = '%s -> %s' % (host, self.runner.delegate_to)
|
||||
|
||||
item = None
|
||||
if type(results) == dict:
|
||||
|
@ -465,9 +464,8 @@ class PlaybookRunnerCallbacks(DefaultRunnerCallbacks):
|
|||
super(PlaybookRunnerCallbacks, self).on_unreachable(host, results)
|
||||
|
||||
def on_failed(self, host, results, ignore_errors=False):
|
||||
delegate_to = self.runner.module_vars.get('delegate_to')
|
||||
if delegate_to:
|
||||
host = '%s -> %s' % (host, delegate_to)
|
||||
if self.runner.delegate_to:
|
||||
host = '%s -> %s' % (host, self.runner.delegate_to)
|
||||
|
||||
results2 = results.copy()
|
||||
results2.pop('invocation', None)
|
||||
|
@ -500,9 +498,8 @@ class PlaybookRunnerCallbacks(DefaultRunnerCallbacks):
|
|||
super(PlaybookRunnerCallbacks, self).on_failed(host, results, ignore_errors=ignore_errors)
|
||||
|
||||
def on_ok(self, host, host_result):
|
||||
delegate_to = self.runner.module_vars.get('delegate_to')
|
||||
if delegate_to:
|
||||
host = '%s -> %s' % (host, delegate_to)
|
||||
if self.runner.delegate_to:
|
||||
host = '%s -> %s' % (host, self.runner.delegate_to)
|
||||
|
||||
item = host_result.get('item', None)
|
||||
|
||||
|
@ -542,9 +539,8 @@ class PlaybookRunnerCallbacks(DefaultRunnerCallbacks):
|
|||
super(PlaybookRunnerCallbacks, self).on_ok(host, host_result)
|
||||
|
||||
def on_skipped(self, host, item=None):
|
||||
delegate_to = self.runner.module_vars.get('delegate_to')
|
||||
if delegate_to:
|
||||
host = '%s -> %s' % (host, delegate_to)
|
||||
if self.runner.delegate_to:
|
||||
host = '%s -> %s' % (host, self.runner.delegate_to)
|
||||
|
||||
if constants.DISPLAY_SKIPPED_HOSTS:
|
||||
msg = ''
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue