diff --git a/connection/ssh.py b/connection/ssh.py index 2e4e1ff..1931e60 100644 --- a/connection/ssh.py +++ b/connection/ssh.py @@ -58,8 +58,10 @@ class Connection(SSH.Connection): self.physical_host = self._play_context.physical_host else: self.physical_host = None + + def set_host_overrides(self, host, hostvars=None): if self._container_check() or self._chroot_check(): - self.host = self._play_context.remote_addr = self.physical_host + self.host = self._play_context.remote_addr = hostvars.get('physical_host_addr') def exec_command(self, cmd, in_data=None, sudoable=True): """run a command on the remote host.""" @@ -149,4 +151,3 @@ class Connection(SSH.Connection): cmd = map(SSH.to_bytes, cmd) p = SSH.subprocess.Popen(cmd, stdin=SSH.subprocess.PIPE, stdout=SSH.subprocess.PIPE, stderr=SSH.subprocess.PIPE) p.communicate() - diff --git a/strategy/linear.py b/strategy/linear.py index dbece34..dd3486a 100644 --- a/strategy/linear.py +++ b/strategy/linear.py @@ -112,6 +112,9 @@ class StrategyModule(LINEAR.StrategyModule): return _play_context = copy.deepcopy(play_context) + if 'physical_host' in host.vars: + physical_host = self._inventory.get_host_variables(host.vars['physical_host']) + host.set_variable('physical_host_addr', physical_host['ansible_host']) if task.delegate_to: # If a task uses delegation change the play_context # to use paramiko with pipelining disabled for this