become root user using custom command in ansible

56 views
Skip to first unread message

Hanumantha Reddy Basireddy

unread,
Nov 23, 2021, 8:06:58 AM11/23/21
to Ansible Project

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.

steve missoh

unread,
Nov 23, 2021, 8:32:22 AM11/23/21
to Ansible Project
You need to configure sudo on the target server.
and then use
become_method = sudo
become = yes
in your  ansible.cfg

HanumanthaReddy

unread,
Nov 23, 2021, 9:13:21 AM11/23/21
to ansible...@googlegroups.com
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.

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/b0c02cf9-196c-4b34-92fe-b638248f9fb8n%40googlegroups.com.


--

ద్వేషించేందుకు జీవిత కాలం సరిపోదు కాబట్టి క్షమించడం అలవర్చుకోండి.

steve missoh

unread,
Nov 23, 2021, 9:28:20 AM11/23/21
to Ansible Project
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 ?
Reply all
Reply to author
Forward
0 new messages