mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
fixes play context connection user (#21776)
Does't map remote_user back into vars if connection is local to preserve the user variable. This is done to be able to set connection_user prop in play_context for the network_cli plugin connection
This commit is contained in:
parent
93ac278f4c
commit
58ee661437
1 changed files with 5 additions and 1 deletions
|
@ -443,7 +443,7 @@ class PlayContext(Base):
|
|||
# additionally, we need to do this check after final connection has been
|
||||
# correctly set above ...
|
||||
if new_info.connection == 'local':
|
||||
new_info.connection_user = self.remote_user
|
||||
new_info.connection_user = new_info.remote_user
|
||||
new_info.remote_user = pwd.getpwuid(os.getuid()).pw_name
|
||||
|
||||
# set no_log to default if it was not previouslly set
|
||||
|
@ -597,6 +597,10 @@ class PlayContext(Base):
|
|||
if 'become' in prop:
|
||||
continue
|
||||
|
||||
# perserves the user var for local connections
|
||||
if self.connection == 'local' and 'remote_user' in prop:
|
||||
continue
|
||||
|
||||
var_val = getattr(self, prop)
|
||||
for var_opt in var_list:
|
||||
if var_opt not in variables and var_val is not None:
|
||||
|
|
Loading…
Reference in a new issue