remove redundant remote_user for local setting
local action plugin already does and this also should fix fork/thread issue by removing use of pwd library fixes #59642
This commit is contained in:
parent
5fb6280672
commit
488b9d6c35
3 changed files with 4 additions and 8 deletions
|
@ -0,0 +1,2 @@
|
||||||
|
bugfixes:
|
||||||
|
- remove redundant remote_user setting in play_context for local as plugin already does it, also removes fork/thread issue from use of pwd library.
|
|
@ -22,7 +22,6 @@ from __future__ import (absolute_import, division, print_function)
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import pwd
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from ansible import constants as C
|
from ansible import constants as C
|
||||||
|
@ -313,15 +312,11 @@ class PlayContext(Base):
|
||||||
elif getattr(new_info, 'connection', None) == 'local' and (not remote_addr_local or not inv_hostname_local):
|
elif getattr(new_info, 'connection', None) == 'local' and (not remote_addr_local or not inv_hostname_local):
|
||||||
setattr(new_info, 'connection', C.DEFAULT_TRANSPORT)
|
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
|
|
||||||
# this ensures any become settings are obeyed correctly
|
|
||||||
# we store original in 'connection_user' for use of network/other modules that fallback to it as login user
|
# we store original in 'connection_user' for use of network/other modules that fallback to it as login user
|
||||||
# connection_user to be deprecated once connection=local is removed for
|
# connection_user to be deprecated once connection=local is removed for, as local resets remote_user
|
||||||
# network modules
|
|
||||||
if new_info.connection == 'local':
|
if new_info.connection == 'local':
|
||||||
if not new_info.connection_user:
|
if not new_info.connection_user:
|
||||||
new_info.connection_user = new_info.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 previously set
|
# set no_log to default if it was not previously set
|
||||||
if new_info.no_log is None:
|
if new_info.no_log is None:
|
||||||
|
|
|
@ -49,8 +49,7 @@ class Connection(ConnectionBase):
|
||||||
''' connect to the local host; nothing to do here '''
|
''' connect to the local host; nothing to do here '''
|
||||||
|
|
||||||
# Because we haven't made any remote connection we're running as
|
# Because we haven't made any remote connection we're running as
|
||||||
# the local user, rather than as whatever is configured in
|
# the local user, rather than as whatever is configured in remote_user.
|
||||||
# remote_user.
|
|
||||||
self._play_context.remote_user = getpass.getuser()
|
self._play_context.remote_user = getpass.getuser()
|
||||||
|
|
||||||
if not self._connected:
|
if not self._connected:
|
||||||
|
|
Loading…
Add table
Reference in a new issue