Pavanan M S
Pavanan M S

Reputation: 157

Not able to become a different sudo user using ansible in GCE

My sample ansible playbook that i tried

https://gist.github.com/pavananms/a7a99a8b1f50ea3ab70e8dddbf4cb56c

I am running the above script as
ansible-playbook test.yml

Upvotes: 0

Views: 430

Answers (2)

user2983509
user2983509

Reputation: 232

If you are using devops user for ansible ssh login & trying to become a sudo then add below entry to /etc/sudoers file on target/remote server.

devops ALL=(ALL) NOPASSWD:ALL

Passing any password in command as a plain text is risky for an env, to pass in ansible playbook or command always use ansible vault.

Upvotes: 0

Raul Hugo
Raul Hugo

Reputation: 1136

If you don't want a password to become to the app_user, you need add this line into /etc/sudoers file:

app_user        ALL=(ALL:ALL) ALL

But if you see my test case here:

https://gist.github.com/sherlockholmes/63607e10457d260c5d7c61bfc1f74fad

The password is of the firt user, in my case the vagrant user. You could pass this password as an extra variable.

--extra-vars='ansible_become_pass=4nsible'

Upvotes: 1

Related Questions