mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Properly switch to the default transport when delegating from localhost
This commit is contained in:
parent
97c2b2ecc5
commit
284bd118a0
1 changed files with 15 additions and 5 deletions
|
@ -350,11 +350,21 @@ class PlayContext(Base):
|
||||||
elif new_info.become_method == 'su' and new_info.su_pass:
|
elif new_info.become_method == 'su' and new_info.su_pass:
|
||||||
setattr(new_info, 'become_pass', new_info.su_pass)
|
setattr(new_info, 'become_pass', new_info.su_pass)
|
||||||
|
|
||||||
|
# special overrides for the connection setting
|
||||||
# finally, in the special instance that the task was specified
|
if len(delegated_vars) > 0:
|
||||||
# as a local action, override the connection in case it was changed
|
# in the event that we were using local before make sure to reset the
|
||||||
# during some other step in the process
|
# connection type to the default transport for the delegated-to host,
|
||||||
if task._local_action:
|
# if not otherwise specified
|
||||||
|
for connection_type in MAGIC_VARIABLE_MAPPING.get('connection'):
|
||||||
|
if connection_type in delegated_vars:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
if getattr(new_info, 'connection', None) == 'local' and new_info.remote_addr not in C.LOCALHOST:
|
||||||
|
setattr(new_info, 'connection', C.DEFAULT_TRANSPORT)
|
||||||
|
elif task._local_action:
|
||||||
|
# otherwise, in the special instance that the task was specified
|
||||||
|
# as a local action, override the connection in case it was changed
|
||||||
|
# during some other step in the process
|
||||||
setattr(new_info, 'connection', 'local')
|
setattr(new_info, 'connection', 'local')
|
||||||
|
|
||||||
# set no_log to default if it was not previouslly set
|
# set no_log to default if it was not previouslly set
|
||||||
|
|
Loading…
Reference in a new issue