Hi guys,
I just started using ansible, and chatting with some of you on the freenode irc server I asked about which would be the best approach to execute shell commands on a login shell.
After some discussion, the solution was to add the flag -i to the sudo_user parameter, something like this:
- name: rbenv | check ruby installed
shell: rbenv versions | grep {{ ruby_version }}
sudo_user: rails -i
register: ruby_installed
ignore_errors: yes
Someone in the chat suggested that maybe adding a parameter to the shell module that used a login shell instead of an interactive one could be useful as a feature.
What do you think about it?
Cheers,
Bernat
Hi Bernat, could you please open a new issue on github for this feature request? The main ansible-project mailing list is for more general purpose questions, while github is used for bugs and feature requests. We also have ansible-devel, if you’d like to discuss the implementation of new features or have any development-related questions. Thanks!
In ansible.cfg you can also change the sudo shell… I don’t know if this is exactly what you are looking for…
all commands executed under sudo are passed as arguments to a shell command
This shell command defaults to /bin/sh
Changing this helps the situation where a user is only allowed to run
e.g. /bin/bash with sudo privileges
executable = /bin/sh
I’ll do that, thanks!
El dijous 7 de novembre de 2013 18:32:55 UTC, James Cammarata va escriure: