# Can't Use Standard become\_method As Have To Use rootsh. Options?

**URL:** <https://forum.ansible.com/t/cant-use-standard-become-method-as-have-to-use-rootsh-options/20822>\
**Category:** Ansible Project\
**Created:** [March 10, 2016, 8:03am UTC](https://forum.ansible.com/t/cant-use-standard-become-method-as-have-to-use-rootsh-options/20822 "2016-03-10T08:03:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Colin\_Anderson](https://avatars.discourse-cdn.com/v4/letter/c/a88e57/32.png) [@Colin\_Anderson](https://forum.ansible.com/u/Colin_Anderson)\
**Post date:** [March 10, 2016, 8:03am UTC](https://forum.ansible.com/t/cant-use-standard-become-method-as-have-to-use-rootsh-options/20822/1 "2016-03-10T08:03:48Z")

</div>

Hi,

The central IT function at my company allows developers root access to a server for a short period of time to allow us to install any required middelware and application software when we are commissioning a server. I’ve been looking at using Ansible to automate this process to prevent user errors and make the process more efficient. The problem that I’ve run into is that they only allow root access using the following sudo call:

`sudo rootsh -i -u root`

This uses a logging shell wrapper, rootsh ([man page](http://linux.die.net/man/1/rootsh)), to log all terminal input and output for audit purposes. We can’t change this and it means we can’t use any of the standard become\_methods that Ansible uses.

Is there any way of adding a become\_method to Ansible that would call the above command instead of just sudo? Alternatively, is there anyway of getting Ansible to run rootsh when it requests elevated privileges?

I did try the following in the vain hope that it might work, but as I feared, it failed:

site.yml:

`

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [March 10, 2016, 2:59pm UTC](https://forum.ansible.com/t/cant-use-standard-become-method-as-have-to-use-rootsh-options/20822/2 "2016-03-10T14:59:07Z")

</div>

you can try setting the sudo exe to ‘sudo rootsh’ and add -i as a sudo flag (though ansible tries to avoid login shells for good reasons).

---

<div class="post-metadata">

**Author:** ![Cristian\_Bratu](https://avatars.discourse-cdn.com/v4/letter/c/ee7513/32.png) [@Cristian\_Bratu](https://forum.ansible.com/u/Cristian_Bratu)\
**Post date:** [May 25, 2016, 2:54pm UTC](https://forum.ansible.com/t/cant-use-standard-become-method-as-have-to-use-rootsh-options/20822/3 "2016-05-25T14:54:50Z")

</div>

Hey Colin,

Have you had any luck with this? I’m running into some very similar issues.

Thanks!

---

<div class="post-metadata">

**Author:** ![Holger\_Foerster](https://avatars.discourse-cdn.com/v4/letter/h/c67d28/32.png) [@Holger\_Foerster](https://forum.ansible.com/u/Holger_Foerster)\
**Post date:** [October 24, 2017, 1:11pm UTC](https://forum.ansible.com/t/cant-use-standard-become-method-as-have-to-use-rootsh-options/20822/4 "2017-10-24T13:11:15Z")

</div>

here my solution:

ansible\_host:  
egrep “^sudo\_exe|^sudo\_flags” /etc/ansible/ansible.cfg  
sudo\_exe = /tmp/ansible\_wrapper  
sudo\_flags =

target\_host:  
cat /tmp/ansible\_wrapper  
shift  
shift  
sudo /usr/bin/rootsh -u root – $@

playbook to create ansible\_wrapper:

---

<div class="post-metadata">

**Author:** ![Nirjas\_Jakilim](https://avatars.discourse-cdn.com/v4/letter/n/f1d935/32.png) [@Nirjas\_Jakilim](https://forum.ansible.com/u/Nirjas_Jakilim)\
**Post date:** [April 26, 2024, 1:18pm UTC](https://forum.ansible.com/t/cant-use-standard-become-method-as-have-to-use-rootsh-options/20822/5 "2024-04-26T13:18:21Z")

</div>

Hi, I have used the wrapper method. but it’s giving me the privilege escalation time out error.  
Ansible Timeout (12s) waiting for privilege escalation prompt  
Can you please tell me what you have used on the playbook after setting the wrapper? Thanks.
