Maybe a dumb question…
I detected sudo_user is not loading the target user environment using the shell module.
When running it super verbose:
/bin/sh -c 'sudo -k && sudo -H -S -p “[sudo via ansible, key=wfaxytdcpsvwjtbbthcpmjnrnxmnxark] password: " -u deploy /bin/sh -c '”'“'/usr/bin/python /tmp/ansible-1379521443.11-262912739079441/command'”'"''
I can found this PR https://github.com/ansible/ansible/commit/224b503b78a5e84cf9a28c03b3087f1ab3202768 but I don’t know if it’s something related.
Adding -i and running from the command line this outputs the correct env:
sudo -k && sudo -H -S -p "[sudo via ansible, key=wfaxytdcpsvwjtbbthcpmjnrnxmnxark] password: " -i -u deploy /bin/sh -c “env”
This is how it should work?
Which version of ansible are you using, and could you show a bit of the playbook that you’re having a problem with? Also, what is the full command line you’re using?
I’m using 1.3 installed with pip.
A simple task like this:
- name: Precompile assets for {{ application }}
shell: bundle exec rake assets:precompile chdir={{ release_path }}
Sorry, clicked send too fast!
I’m using 1.3 installed with pip.
A simple task like this:
- name: Precompile assets for {{ application }}
shell: bundle exec rake assets:precompile chdir={{ release_path }}
sudo_user: {{ user }}
The full command is nothing more than:
sudo -k && sudo -H -S -p "[sudo via ansible, key=wfaxytdcpsvwjtbbthcpmjnrnxmnxark] password: " -i -u deploy /bin/sh -c “env”
Thanks
sudo_user: "{{ user }}"
need to quote when starting a assignment with {
Brian’s correct, is that the actual playbook or a sample, because I’d expect you to receive a YAML parsing error with what you have above.
Also, could you show the ansible command you’re running, and not the command as displayed from the verbose output? The -i flag for ansible commands is the inventory location, so I’m unclear as to why adding that would fix your issue unless your inventory files contain extra parameters. From your original output, it is running the command via sudo as the “deploy” user, it’s just doing it from within a second shell (the reason for all the extra quoting).
Sure it’s a sample I edited my current task for the message. I’m using a workaround just for the record:
vars:
- as_deploy: ‘sudo -u {{ user }} -H bash -l -c’
tasks:
- shell: ‘{{ as_deploy }} “cd {{ release_path }} && bundle exec rake assets:precompile”’
Ahh, I see. Could you open a github issue for this? It may be that it is your PAM settings or something else that is requiring a full initial login via the sudo command, so it may be an option we need to enable.
Thanks!
Sure, thanks. Expect there all details.
El 19/09/2013, a les 12:51, James Cammarata <jcammarata@ansibleworks.com> va escriure: