Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to achieve sudo su - <user> and run all command in ansible

Tags:

ansible

I have an ssh access to the box but to run certain commands I need to do sudo su - and enter the password. Then I can run all the commands under that user.

How can i achieve this ansible. I tried become and sudo nothing worked for me.

Can someone provide me a working example?

like image 508
mohan Avatar asked Oct 28 '25 15:10

mohan


1 Answers

this is what working for me ...

become: yes
become_method: sudo
become_user: myuser
become_flags: 'su -c'
like image 118
Shirish Shukla Avatar answered Oct 31 '25 11:10

Shirish Shukla



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!