become root user using custom command in ansible

Hello All,

In target server need to run a command like “mcs cmh” which prompts for password to become root user… how can I achieve the same in become method?

Thanks,

BHR.

You need to configure sudo on the target server.
and then use

become_method = sudo
become = yes

in your ansible.cfg

As per my understanding if we are able to run command sudo su - root in target server then can use become_method as sudo… but need to run custom command mcs cmh to login as root user in target server. I don’t think so we can use become_metod = sudo in this scenario.

Not use I get all your explanations, but maybe u can also look at:
ansible_become_user=root and ansible_become_pass=XXXX to set in your inventory file ?