Merge branch 'sudo_on_if_needed' of https://github.com/apollo13/ansible into apollo13-sudo_on_if_needed

This commit is contained in:
James Cammarata 2015-09-17 11:03:27 -04:00
commit ba82e57445
4 changed files with 73 additions and 1 deletions

View file

@ -453,7 +453,9 @@ class ActionBase:
self._display.debug("no command, exiting _low_level_execute_command()")
return dict(stdout='', stderr='')
if sudoable and self._play_context.become:
allow_same_user = C.BECOME_ALLOW_SAME_USER
same_user = self._play_context.become_user == self._play_context.remote_user
if sudoable and self._play_context.become and (allow_same_user or not same_user):
self._display.debug("using become for this command")
cmd = self._play_context.make_become_cmd(cmd, executable=executable)