mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
fixes #16865 : we should properly determine connection type for delegated task first, before overriding remote user for local connections (#17723)
This commit is contained in:
parent
a64266e7f5
commit
da5b0c39c9
1 changed files with 8 additions and 6 deletions
|
@ -415,12 +415,6 @@ class PlayContext(Base):
|
|||
if new_info.port is None and C.DEFAULT_REMOTE_PORT is not None:
|
||||
new_info.port = int(C.DEFAULT_REMOTE_PORT)
|
||||
|
||||
# if the final connection type is local, reset the remote_user value
|
||||
# to that of the currently logged in user, to ensure any become settings
|
||||
# are obeyed correctly
|
||||
if new_info.connection == 'local':
|
||||
new_info.remote_user = pwd.getpwuid(os.getuid()).pw_name
|
||||
|
||||
# special overrides for the connection setting
|
||||
if len(delegated_vars) > 0:
|
||||
# in the event that we were using local before make sure to reset the
|
||||
|
@ -437,6 +431,14 @@ class PlayContext(Base):
|
|||
elif getattr(new_info, 'connection', None) == 'local' and (not remote_addr_local or not inv_hostname_local):
|
||||
setattr(new_info, 'connection', C.DEFAULT_TRANSPORT)
|
||||
|
||||
# if the final connection type is local, reset the remote_user value
|
||||
# to that of the currently logged in user, to ensure any become settings
|
||||
# are obeyed correctly
|
||||
# additionally, we need to do this check after final connection has been
|
||||
# correctly set above ...
|
||||
if new_info.connection == 'local':
|
||||
new_info.remote_user = pwd.getpwuid(os.getuid()).pw_name
|
||||
|
||||
# set no_log to default if it was not previouslly set
|
||||
if new_info.no_log is None:
|
||||
new_info.no_log = C.DEFAULT_NO_LOG
|
||||
|
|
Loading…
Reference in a new issue