# Issues using pbrun with ansible

**URL:** <https://forum.ansible.com/t/issues-using-pbrun-with-ansible/24613>\
**Category:** Ansible Project\
**Created:** [May 31, 2017, 5:35pm UTC](https://forum.ansible.com/t/issues-using-pbrun-with-ansible/24613 "2017-05-31T17:35:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![pallav\_verma](https://avatars.discourse-cdn.com/v4/letter/p/f6c823/32.png) [@pallav\_verma](https://forum.ansible.com/u/pallav_verma)\
**Post date:** [May 31, 2017, 5:35pm UTC](https://forum.ansible.com/t/issues-using-pbrun-with-ansible/24613/1 "2017-05-31T17:35:02Z")

</div>

Can you please help me with the below:

In my org, I am not allowed to use root as a username while elevating my access. I need to use the below commands:

pbrun /bin/su -

I can also use the below:

pbrun -u myusername /bin/su -

Could you please let me know the config I should place in my playbook to achieve this.

I have tried several combinations of the become parameters without luck.

---

<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:** [June 2, 2017, 10:39pm UTC](https://forum.ansible.com/t/issues-using-pbrun-with-ansible/24613/2 "2017-06-02T22:39:53Z")

</div>

Ansible does not handle 'chaining' of methods .. also it is redundant  
to use pbrun and su, you can either get a shell directly or just use  
pbrun to execute things the same way su does.

But if you have no control over the settings, you might be able to  
'hack' the become\_exe settings to use 'pbrun su' and use pbrun or su  
as your become\_method.

---

<div class="post-metadata">

**Author:** ![pallav\_verma](https://avatars.discourse-cdn.com/v4/letter/p/f6c823/32.png) [@pallav\_verma](https://forum.ansible.com/u/pallav_verma)\
**Post date:** [June 3, 2017, 5:42am UTC](https://forum.ansible.com/t/issues-using-pbrun-with-ansible/24613/3 "2017-06-03T05:42:03Z")

</div>

Thanks Brian!

I did try to modify the become.exe settings for prune but it did not resolve my issue. On trying to remove the  
-u parameter, I received timeout when ansible tried to execute the resulting command: pbrun /bin/su -

On trying to alter the settings to pbrun -u myusername /bin/su -, the system did not even execute the pbrun block.  
Perhaps the answer is that the system sees no sense in using -u parameter with the same username as that of the  
remote\_username. Unfortunately, that is precisely what I need to achieve to switch to root.

Please let me know if I am missing something or there is anything else I can try out.

---

<div class="post-metadata">

**Author:** ![David\_Cottrell](https://avatars.discourse-cdn.com/v4/letter/d/839c29/32.png) [@David\_Cottrell](https://forum.ansible.com/u/David_Cottrell)\
**Post date:** [July 16, 2017, 4:39pm UTC](https://forum.ansible.com/t/issues-using-pbrun-with-ansible/24613/4 "2017-07-16T16:39:12Z")

</div>

I think I am hitting the same issues … some notes here.

Only “pbrun /bin/su -” is allowed. No extra commands. No “pbrun my\_command.sh”. I think this breaks ansible assumptions but is probably fixable with a bit of work. Probably need to send all following commands through STDIN (p.poll()/p.communicate etc) but I need to understand more about how ansible works … looks like a bit of a hacky state machine with text based triggers.

[https://github.com/ansible/ansible/issues/26857](https://github.com/ansible/ansible/issues/26857)

---

<div class="post-metadata">

**Author:** ![Uj1](https://avatars.discourse-cdn.com/v4/letter/u/45deac/32.png) [@Uj1](https://forum.ansible.com/u/Uj1)\
**Post date:** [January 12, 2018, 2:51am UTC](https://forum.ansible.com/t/issues-using-pbrun-with-ansible/24613/5 "2018-01-12T02:51:57Z")

</div>

how to did you modified the become.exe settings. In my case ansible is executing the command as “pbrun /bin/su - -u suername”. However if if it get executed as “pbrun -u username /bin/su -” then it will be able to switch to root
