Actually fix connection plugin physical host var

If ansible_host is defined on the physical_host inventory item,
physical_host_addr will be set and used as the ssh destination.

However if ansible_host is not defined, we will fall back to the
physical_host inventory hostname.

Related-Bug: 1695944
Change-Id: I90ccc12fd044f08a60c84f0b8ae5d7fd783760dd
This commit is contained in:
Logan V 2017-06-10 00:42:02 -05:00 committed by Jean-Philippe Evrard
parent d91d203361
commit 3ac24525fd

View File

@ -62,8 +62,9 @@ class Connection(SSH.Connection):
def set_host_overrides(self, host, hostvars=None):
if self._container_check() or self._chroot_check():
physical_host_addr = hostvars.get('physical_host_addr')
if physical_host_addr:
self.host = self._play_context.remote_addr = physical_host_addr
if not physical_host_addr:
physical_host_addr = self.physical_host
self.host = self._play_context.remote_addr = physical_host_addr
def exec_command(self, cmd, in_data=None, sudoable=True):
"""run a command on the remote host."""