Skip to content

Commit

Permalink
if users are None/empty, dont assume sameness (#58875)
Browse files Browse the repository at this point in the history
(cherry picked from commit 4ef2545)

 also fix all cases of none remote/become users (#59397)
 some cases failed, when defaults were None on the plugins

(cherry picked from commit 74ac229)
  • Loading branch information
bcoca authored and abadger committed Jul 23, 2019
1 parent 89963a0 commit 37f8684
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/become_none.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- Do not assume None is equal as connection and become tools can have different unspecified defaults.
8 changes: 5 additions & 3 deletions lib/ansible/plugins/action/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1035,9 +1035,11 @@ def _low_level_execute_command(self, cmd, sudoable=True, in_data=None, executabl
display.debug("_low_level_execute_command(): changing cwd to %s for this command" % chdir)
cmd = self._connection._shell.append_command('cd %s' % chdir, cmd)

if (sudoable and self._connection.transport != 'network_cli' and self._connection.become and
(C.BECOME_ALLOW_SAME_USER or
self.get_become_option('become_user') != self._get_remote_user())):
ruser = self._get_remote_user()
buser = self.get_become_option('become_user')
if (sudoable and self._connection.become and # if sudoable and have become
self._connection.transport != 'network_cli' and # if not using network_cli
(C.BECOME_ALLOW_SAME_USER or (buser != ruser or not any((ruser, buser))))): # if we allow same user PE or users are different and either is set
display.debug("_low_level_execute_command(): using become for this command")
cmd = self._connection.become.build_become_command(cmd, self._connection._shell)

Expand Down

0 comments on commit 37f8684

Please sign in to comment.