Also make sure remote_user is defaulted correctly for delegated hosts
Fixes #13323
This commit is contained in:
parent
e2ddc2f6ab
commit
dc0fae1af7
2 changed files with 10 additions and 0 deletions
|
@ -334,6 +334,8 @@ class PlayContext(Base):
|
|||
display.debug("no remote address found for delegated host %s\nusing its name, so success depends on DNS resolution" % delegated_host_name)
|
||||
delegated_vars['ansible_host'] = delegated_host_name
|
||||
|
||||
# reset the port back to the default if none was specified, to prevent
|
||||
# the delegated host from inheriting the original host's setting
|
||||
for port_var in MAGIC_VARIABLE_MAPPING.get('port'):
|
||||
if port_var in delegated_vars:
|
||||
break
|
||||
|
@ -342,6 +344,13 @@ class PlayContext(Base):
|
|||
delegated_vars['ansible_port'] = 5986
|
||||
else:
|
||||
delegated_vars['ansible_port'] = C.DEFAULT_REMOTE_PORT
|
||||
|
||||
# and likewise for the remote user
|
||||
for user_var in MAGIC_VARIABLE_MAPPING.get('remote_user'):
|
||||
if user_var in delegated_vars:
|
||||
break
|
||||
else:
|
||||
delegated_vars['ansible_user'] = None
|
||||
else:
|
||||
delegated_vars = dict()
|
||||
|
||||
|
|
|
@ -91,6 +91,7 @@ class TestPlayContext(unittest.TestCase):
|
|||
mock_task.become_user = 'mocktaskroot'
|
||||
mock_task.become_pass = 'mocktaskpass'
|
||||
mock_task._local_action = False
|
||||
mock_task.delegate_to = None
|
||||
|
||||
all_vars = dict(
|
||||
ansible_connection = 'mock_inventory',
|
||||
|
|
Loading…
Reference in a new issue