1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Update lib/ansible/utils/__init__.py

Adds -i to  make_sudo_cmd so target user's environment gets loaded when configurationslike this are used :


    - hosts: ubuntu 
      name: Install ruby for the configured ruby user 
      sudo: True 
      sudo_user: rubyuser 
      # should be ${ruby_user}, but can't for now because of #1665 
      tasks: 
      - name: Gets current ruby version 
        action: shell rbenv version 
        register: ruby_current_version
This commit is contained in:
Michel Blanc 2013-01-18 16:03:50 +01:00
parent f86974fdae
commit 87f6739e20

View file

@ -544,6 +544,6 @@ def make_sudo_cmd(sudo_user, executable, cmd):
# the -p option. # the -p option.
randbits = ''.join(chr(random.randint(ord('a'), ord('z'))) for x in xrange(32)) randbits = ''.join(chr(random.randint(ord('a'), ord('z'))) for x in xrange(32))
prompt = '[sudo via ansible, key=%s] password: ' % randbits prompt = '[sudo via ansible, key=%s] password: ' % randbits
sudocmd = 'sudo -k && sudo -S -p "%s" -u %s %s -c %s' % ( sudocmd = 'sudo -k && sudo -S -p "%s" -i -u %s %s -c %s' % (
prompt, sudo_user, executable or '$SHELL', pipes.quote(cmd)) prompt, sudo_user, executable or '$SHELL', pipes.quote(cmd))
return ('/bin/sh -c ' + pipes.quote(sudocmd), prompt) return ('/bin/sh -c ' + pipes.quote(sudocmd), prompt)