# Customizing how 'su' is used?

**URL:** <https://forum.ansible.com/t/customizing-how-su-is-used/17221>\
**Category:** Ansible Project\
**Created:** [January 8, 2015, 9:14pm UTC](https://forum.ansible.com/t/customizing-how-su-is-used/17221 "2015-01-08T21:14:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ian\_Whitney](https://avatars.discourse-cdn.com/v4/letter/i/e99b99/32.png) [@Ian\_Whitney](https://forum.ansible.com/u/Ian_Whitney)\
**Post date:** [January 8, 2015, 9:14pm UTC](https://forum.ansible.com/t/customizing-how-su-is-used/17221/1 "2015-01-08T21:14:44Z")

</div>

Hi,

I’ve been learning Ansible and have run into a behavior that causes problems with the server setup here at work. I’m wondering if there’s a way to fix it.

On our server I have to run certain commands as an admin user. But I can’t just switch users with ‘su superuser’. I have to execute su with sudo. So, ‘sudo su superuser’.

If I do:

ansible all -a “whoami” -R superuser

Then the command hangs, as the server is asking for a password, which I do not have.

And if I do:

ansible all -a “whoami” -s -R superuser

I get the error message about trying to combine sudo and su.

Do I have options?

Thanks,

Ian

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [January 8, 2015, 11:46pm UTC](https://forum.ansible.com/t/customizing-how-su-is-used/17221/2 "2015-01-08T23:46:39Z")

</div>

There aren’t any options for sudo + su together.

Are you sure you can’t just and skip the su’ing?

---

<div class="post-metadata">

**Author:** ![Ian\_Whitney](https://avatars.discourse-cdn.com/v4/letter/i/e99b99/32.png) [@Ian\_Whitney](https://forum.ansible.com/u/Ian_Whitney)\
**Post date:** [January 9, 2015, 12:14am UTC](https://forum.ansible.com/t/customizing-how-su-is-used/17221/3 "2015-01-09T00:14:18Z")

</div>

Can not. This a battle that has come up before.

Although it’s a very different tool, I know that Capistrano I can override how it calls certain shell commands. Is such a thing possible in Ansible? If so, I could just turn all use of “su” into “sudo su”

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [January 9, 2015, 4:54pm UTC](https://forum.ansible.com/t/customizing-how-su-is-used/17221/4 "2015-01-09T16:54:16Z")

</div>

Replacing the name of the command is not presently possible – Sudo flags (those sent to sudo) are controllable, however.
