# Sudo'ing to a particular user now possible in the development branch (0.4)

**URL:** <https://forum.ansible.com/t/sudoing-to-a-particular-user-now-possible-in-the-development-branch-0-4/11512>\
**Category:** Ansible Project\
**Created:** [May 7, 2012, 12:10am UTC](https://forum.ansible.com/t/sudoing-to-a-particular-user-now-possible-in-the-development-branch-0-4/11512 "2012-05-07T00:10:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [May 7, 2012, 12:10am UTC](https://forum.ansible.com/t/sudoing-to-a-particular-user-now-possible-in-the-development-branch-0-4/11512/1 "2012-05-07T00:10:18Z")

</div>

Hi folks,

It is now possible on the devel branch to sudo to a particular user  
where that user is NOT root. This is based on a patch from  
weaselkeeper, who gets the award for the best handle on all of github,  
plus some minor tweaks to make it work better with playbooks.

Usage from the command line is pretty simple:

ansible all -m ping -u yourUserName -s -U otherUserName

And from playbooks, there is a new playbook level variable available:

"sudo\_user"

(As I have mentioned, I am working to make it available to specify  
these kinds of things in the inventory file. This is coming.)

Sidenote -- no documentation on this feature just yet aside from this  
email. At this point on the devel branch, after getting variable  
handling between playbooks and the inventory file more unified, I'm  
going to take a decent time off to update documentation -- we have  
QUITE a few things in 0.4 to reflect. These will probably all start  
with "(new in 0.4)" as it's not only useful development branch info,  
it's also useful for encourage 0.3 users to upgrade once 0.4 is  
released.

As with all things, help testing this is very welcome. From what  
I've tried, it seems to be good. I have tried sudo'ing to batman,  
for instance, and it would not let me... because I am not batman.

--Michael

---

<div class="post-metadata">

**Author:** ![John\_Callender](https://avatars.discourse-cdn.com/v4/letter/j/b5ac83/32.png) [@John\_Callender](https://forum.ansible.com/u/John_Callender)\
**Post date:** [May 7, 2012, 2:27am UTC](https://forum.ansible.com/t/sudoing-to-a-particular-user-now-possible-in-the-development-branch-0-4/11512/2 "2012-05-07T02:27:36Z")

</div>

So you say. But Bruce Wayne said the same thing many times. The question  
is, have you and Batman ever been seen at the same place at the same time?

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [May 7, 2012, 3:04am UTC](https://forum.ansible.com/t/sudoing-to-a-particular-user-now-possible-in-the-development-branch-0-4/11512/3 "2012-05-07T03:04:35Z")

</div>

> > As with all things, help testing this is very welcome. From what  
> > I’ve tried, it seems to be good. I have tried sudo’ing to batman,  
> > for instance, and it would not let me… because I am not batman.
> 
> So you say. But Bruce Wayne said the same thing many times. The question  
> is, have you and Batman ever been seen at the same place at the same time?

This is a very good question.
