mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Don't use local transport for delegated hosts if the inventory_hostname isn't local
For some situations like Vagrant, the remote_addr may be a localhost addr, but ssh is still desired. This corrects the assumption that any localhost remote_addr should be using the local connection by checking the inventory_hostname value as well. Fixes #12817
This commit is contained in:
parent
99e7bb35c1
commit
b46ce47a84
1 changed files with 4 additions and 2 deletions
|
@ -357,9 +357,11 @@ class PlayContext(Base):
|
|||
if connection_type in delegated_vars:
|
||||
break
|
||||
else:
|
||||
if new_info.remote_addr in C.LOCALHOST:
|
||||
remote_addr_local = new_info.remote_addr in C.LOCALHOST
|
||||
inv_hostname_local = delegated_vars.get('inventory_hostname') in C.LOCALHOST
|
||||
if remote_addr_local and inv_hostname_local:
|
||||
setattr(new_info, 'connection', 'local')
|
||||
elif getattr(new_info, 'connection', None) == 'local' and new_info.remote_addr not in C.LOCALHOST:
|
||||
elif getattr(new_info, 'connection', None) == 'local' and (not remote_addr_local or not inv_hostname_local):
|
||||
setattr(new_info, 'connection', C.DEFAULT_TRANSPORT)
|
||||
|
||||
# set no_log to default if it was not previouslly set
|
||||
|
|
Loading…
Reference in a new issue