diff options
author | James Cammarata <jimi@sngx.net> | 2016-01-18 13:47:52 -0500 |
---|---|---|
committer | James Cammarata <jimi@sngx.net> | 2016-01-18 13:48:01 -0500 |
commit | b769426c8f7c022c9c679406c2ec3bb1e91273af (patch) | |
tree | 302de0cf026f475b3824b0ffe9734b2aec3b346a | |
parent | 36aa89ac7e77dde7fba7a14db21845a456577b46 (diff) | |
parent | c42484a0297a9372a6864e06849cb540c5b272ca (diff) | |
download | ansible-b769426c8f7c022c9c679406c2ec3bb1e91273af.tar.gz |
Merge branch 'ktaragorn-patch-1' into devel
-rw-r--r-- | lib/ansible/executor/task_executor.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/ansible/executor/task_executor.py b/lib/ansible/executor/task_executor.py index 4a2d30a2cd..5f9cccae4c 100644 --- a/lib/ansible/executor/task_executor.py +++ b/lib/ansible/executor/task_executor.py @@ -316,6 +316,11 @@ class TaskExecutor: # do the same kind of post validation step on it here before we use it. self._play_context.post_validate(templar=templar) + # now that the play context is finalized, if the remote_addr is not set + # default to using the host's address field as the remote address + if not self._play_context.remote_addr: + self._play_context.remote_addr = self._host.address + # We also add "magic" variables back into the variables dict to make sure # a certain subset of variables exist. self._play_context.update_vars(variables) @@ -365,6 +370,10 @@ class TaskExecutor: if not self._connection or not getattr(self._connection, 'connected', False): self._connection = self._get_connection(variables=variables, templar=templar) self._connection.set_host_overrides(host=self._host) + else: + # if connection is reused, its _play_context is no longer valid and needs + # to be replaced with the one templated above, in case other data changed + self._connection._play_context = self._play_context self._handler = self._get_action_handler(connection=self._connection, templar=templar) @@ -544,9 +553,6 @@ class TaskExecutor: correct connection object from the list of connection plugins ''' - if not self._play_context.remote_addr: - self._play_context.remote_addr = self._host.address - if self._task.delegate_to is not None: # since we're delegating, we don't want to use interpreter values # which would have been set for the original target host |