Open conorgil opened 8 years ago
With some additional trial/error, I realized by looking in the role.yml
file used for testing that it calls the role and specifies sudo: yes
when calling the role instead of having each task within the role define sudo: yes
.
I updated my meta/main.yml
file to look like this:
dependencies:
- {
role: "nodesource.node",
sudo: yes
}
and the script worked as expected without error.
I would just close this issue as solved, but it begs the question in my mind: when will we ever not call this role with sudo: yes
? If it is required, then would it be easier to just update the tasks/main.yml
to put that on each task and then folks do not need to worry about setting it when calling the role?
Thoughts appreciated.
@conorgil I also highly recommend to use this in addition to your recommendation:
sudo_user: "{{ ansible_ssh_user}}"
.
Running purely as sudo will run commands as root and leave applications unavailable to the default user.
Just because the script passes, it doesn't mean the user is able to access all of these cool tools (without sudo - best practice!).
I would also recommend changing sudo
to become
and sudo_user
to become_user
purely because the sudo
and sudo_user
modules have been deprecated in later releases.
How I solved this problem:
roles:
- role: nodesource.node
become: yes
I did not see any other issues asking this same question, so I think I must be doing something wrong since it runs for other users. I am running the role and getting errors that
sudo
is required to install the gpg signing key, etc.If I change the role inline to add
sudo: yes
to the following tasks, then it runs correctly without errors.Any advice on what I am doing wrong here would be greatly appreciated. Thanks!