I don't see this change in any current release. Did it get reverted for
some reason?
On Friday, January 18, 2013 4:22:30 AM UTC-5, Michel Blanc wrote:
>
> Hi all,
>
> It seems I can not get the remote user's environment loaded when using
> sudo in a playbook (or at the command line).
>
> Here is an example : I need to retrieve the installed ruby version with
> rbenv. Ruby is installed for user 'rbuser', and rbenv requires .bashrc
> to be loaded so it can be found.
>
> Trying at the command line (or in a playbook with "sudo: True" and
> "sudo_user: rbuser") doesn't work :
>
> ws$ ansible all -m shell -a 'rbenv version' -l goat -U rbuser
> <goat> EXEC /bin/sh -c 'sudo -k && sudo -p "[sudo snip] password: " -u
> rbuser /bin/sh -c '"'"'/usr/bin/python
> /tmp/ansible-1358499444.98-121478482753266/command; rm -rf
> /tmp/ansible-1358499444.98-121478482753266/ >/dev/null 2>&1'"'"''
> goat | FAILED | rc=127 >>
> /bin/sh: 1: rbenv: not found
>
> Trying the geenrated python directly from the node unsurprisingly gives
> the same result :
>
> ws$ ssh root@goat
> root@goat:~ sudo -u rbuser /bin/sh -c '/usr/bin/python
> /tmp/ansible-1358499444.98-121478482753266/command'
> {"changed": true, "end": "2013-01-18 09:57:54.312280", "stdout": "",
> "cmd": "rbenv version ", "start": "2013-01-18 09:57:54.302952", "delta":
> "0:00:00.009328", "stderr": "/bin/sh: 1: rbenv: not found", "rc": 127}
>
> However, when trying with an additional (-i) flag (asking sudo to load
> the user's environment), it works fine :
>
> root@goat:~ sudo -iu rbuser /bin/sh -c '/usr/bin/python
> /tmp/ansible-1358499444.98-121478482753266/command'
> {"changed": true, "end": "2013-01-18 09:58:06.176637", "stdout": "system
> (set by /home/rbuser/.rbenv/version)", "cmd": "rbenv version ", "start":
> "2013-01-18 09:58:06.061737", "delta": "0:00:00.114900", "stderr": "",
> "rc": 0}
>
>
> Am I missing something here ? Should we invoke sudo with -i flag in
> make_sudo_command ?
>
> Thanks,
>
> M
> --
> Michel Blanc - netWorks
> 8A68 0871 747A 65B6 E87C 3BEA 187C 36BB 2CE5 68BD
>
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/a8178455-c76d-439a-be1a-deafb5024967%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.