Reputation: 3380
I normally reach a machine via ssh with the following commands:
ssh [email protected]
Then as "myuser" I become user jboss as follows (No password requested):
$ sudo su - jboss
I need to replicate the same behavior with Ansible but the result is:
fatal: [192.168.10.1] => Missing become password
Here is my yml file:
- name: Hello Ansible - quick start
hosts: webservers
user: myuser
become: true
become_method: sudo
become_user: jboss
tasks:
- name: Hello server
shell: /home/jboss/script.sh
As per documentation it seems correct, however it isn't. Any help?
Upvotes: 2
Views: 2645
Reputation: 47
As I understand the docs, this exact method is not possible.
Only one method may be enabled per host
Methods cannot be chained. You cannot use sudo /bin/su - to become a user, you need to have privileges to run the command as that user in sudo or be able to su directly to it (the same for pbrun, pfexec or other supported methods). source
Maybe "become_method: su" would do the trick.
Upvotes: 1