# HELP: Problem with 'become' and pbrun

**URL:** <https://forum.ansible.com/t/help-problem-with-become-and-pbrun/21044>\
**Category:** Ansible Project\
**Created:** [April 1, 2016, 5:43pm UTC](https://forum.ansible.com/t/help-problem-with-become-and-pbrun/21044 "2016-04-01T17:43:00Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![phillip.corchary](https://avatars.discourse-cdn.com/v4/letter/p/eada6e/32.png) [@phillip.corchary](https://forum.ansible.com/u/phillip.corchary)\
**Post date:** [April 1, 2016, 5:43pm UTC](https://forum.ansible.com/t/help-problem-with-become-and-pbrun/21044/1 "2016-04-01T17:43:00Z")

</div>

I’m relatively experienced with Ansible 1.3, but just now trying to bring Ansible 2.0 for the first time in a new project (and hoping to displace chef). I Have round 1k servers to manage that use pbrun, but others installed and control pbrun,  
I have traditional sudo in a few of these hosts as well, but pbrun is the preferred privilege elevation method

I use all ssh-config auth in the following example.

HELP - I really need to figure this out, as ansible will be mostly useless to me unless I can reliably use it with pbrun

$ ansible all -i myhosts -o -m shell -a ‘uptime’ -b --become-method pbrun  
[c00413.mydom.com](http://c00413.mydom.com) | FAILED! =\> {“changed”: false, “failed”: true, “module\_stderr”: “”, “module\_stdout”: “/bin/bash: pbrun: command not found\r\n”, “msg”: “MODULE FAILURE”, “parsed”: false}  
[c00414.mydom.com](http://c00414.mydom.com) | FAILED! =\> {“changed”: false, “failed”: true, “module\_stderr”: “”, “module\_stdout”: “/bin/bash: pbrun: command not found\r\n”, “msg”: “MODULE FAILURE”, “parsed”: false}  
[c00415.mydom.com](http://c00415.mydom.com) | FAILED! =\> {“changed”: false, “failed”: true, “module\_stderr”: “”, “module\_stdout”: “/bin/bash: pbrun: command not found\r\n”, “msg”: “MODULE FAILURE”, “parsed”: false}  
[c00416.mydom.com](http://c00416.mydom.com) | FAILED! =\> {“changed”: false, “failed”: true, “module\_stderr”: “”, “module\_stdout”: “/bin/bash: pbrun: command not found\r\n”, “msg”: “MODULE FAILURE”, “parsed”: false}  
[c00417.mydom.com](http://c00417.mydom.com) | FAILED! =\> {“changed”: false, “failed”: true, “module\_stderr”: “”, “module\_stdout”: “/bin/bash: pbrun: command not found\r\n”, “msg”: “MODULE FAILURE”, “parsed”: false}  
[c00418.mydom.com](http://c00418.mydom.com) | FAILED! =\> {“changed”: false, “failed”: true, “module\_stderr”: “”, “module\_stdout”: “/bin/bash: pbrun: command not found\r\n”, “msg”: “MODULE FAILURE”, “parsed”: false}

$ ansible all -i myhosts -o -m shell -a ‘uptime’ -b --become-method ‘/opt/pb/bin/pbrun’  
[c00413.mydom.com](http://c00413.mydom.com) | FAILED! =\> {“failed”: true, “msg”: “Privilege escalation method not found: /opt/pb/bin/pbrun”}  
[c00414.mydom.com](http://c00414.mydom.com) | FAILED! =\> {“failed”: true, “msg”: “Privilege escalation method not found: /opt/pb/bin/pbrun”}  
[c00415.mydom.com](http://c00415.mydom.com) | FAILED! =\> {“failed”: true, “msg”: “Privilege escalation method not found: /opt/pb/bin/pbrun”}  
[c00416.mydom.com](http://c00416.mydom.com) | FAILED! =\> {“failed”: true, “msg”: “Privilege escalation method not found: /opt/pb/bin/pbrun”}  
[c00417.mydom.com](http://c00417.mydom.com) | FAILED! =\> {“failed”: true, “msg”: “Privilege escalation method not found: /opt/pb/bin/pbrun”}  
[c00418.mydom.com](http://c00418.mydom.com) | FAILED! =\> {“failed”: true, “msg”: “Privilege escalation method not found: /opt/pb/bin/pbrun”}

**Here is my cfg file … i did make a few changes trying to troubleshoot this**

[defaults]

# some basic default values…

hostfile = ./hosts  
inventory = ./hosts  
library = /usr/share/ansible  
remote\_tmp = $HOME/.ansible/tmp  
pattern = \*  
forks = 20  
poll\_interval = 10  
sudo\_user = root  
transport = ssh  
remote\_port = 22  
module\_lang = C

gathering = implicit

# change this for alternative sudo implementations

#sudo\_exe = sudo \<\<changed this  
#module\_name = shell \<\<changed this  
#ask\_sudo\_pass= true \<\<changed this

executable = /bin/bash \<\<added this

# the message changed when I made that change

#FAILED! =\> {“changed”: false, “failed”: true, “module\_stderr”: “”, “module\_stdout”: “/bin/sh: pbrun: command not found\r\n”, “msg”: “MODULE FAILURE”, “p arsed”: false}

# SSH timeout

timeout = 3

[ssh\_connection]

# ssh arguments to use

# Leaving off ControlPersist will result in poor performance, so use

# paramiko on older platforms rather than removing it

ssh\_args = -o ControlMaster=auto -o ControlPersist=1800s  
#1800 seconds is 30min

---

<div class="post-metadata">

**Author:** ![Johannes\_Kastl](https://avatars.discourse-cdn.com/v4/letter/j/bbe5ce/32.png) [@Johannes\_Kastl](https://forum.ansible.com/u/Johannes_Kastl)\
**Post date:** [April 2, 2016, 7:01pm UTC](https://forum.ansible.com/t/help-problem-with-become-and-pbrun/21044/2 "2016-04-02T19:01:01Z")

</div>

It seems your pbrun executable is not found.

What does this return (if you run it for just one host foobar to test it):

$ ansible foobar -i myhosts -o -m shell -a 'which pbrun'

Johannes

---

<div class="post-metadata">

**Author:** ![phillip.corchary](https://avatars.discourse-cdn.com/v4/letter/p/eada6e/32.png) [@phillip.corchary](https://forum.ansible.com/u/phillip.corchary)\
**Post date:** [April 3, 2016, 7:05pm UTC](https://forum.ansible.com/t/help-problem-with-become-and-pbrun/21044/3 "2016-04-03T19:05:29Z")

</div>

Here is the frustrating thing as seen below. Logging directly in as myself clearly pbrun is found in the path, but ansible fails at the same.

This is an intersting point – how is the scope of the path set for the login session from ansible. it’s different from when I see directly.

**FROM ANSIBLE**  
$ ansible all -i myhosts2 -m shell -a ‘which pbrun’  
[host1.mydom.com](http://host1.mydom.com) | FAILED | rc=1 \>\>  
which: no pbrun in (/usr/lib64/qt-3.3/bin:/usr/local/maven-3.2.1/bin:/usr/local/bin:/bin:/usr/bin)

**FROM LOCAL SHELL ON SAME HOST**  
$ ssh [host1.mydom.com](http://host1.mydom.com)  
Last login: Sun Apr 3 19:00:41 2016 from 16.87.0.70  
$ which pbrun  
/opt/pb/bin/pbrun  
$

$ echo $PATH  
/opt/krb5/sbin/64:/usr/lib64/qt-3.3/bin:/usr/local/maven-3.2.1/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/X11R6/bin:/sbin:/usr/sbin:/usr/bin:/opt/pb/bin:/opt/perf/bin:/bin:/usr/local/bin:/home/corcharp/bin

---

<div class="post-metadata">

**Author:** ![phillip.corchary](https://avatars.discourse-cdn.com/v4/letter/p/eada6e/32.png) [@phillip.corchary](https://forum.ansible.com/u/phillip.corchary)\
**Post date:** [April 4, 2016, 6:01pm UTC](https://forum.ansible.com/t/help-problem-with-become-and-pbrun/21044/4 "2016-04-04T18:01:24Z")

</div>

So this really seem to be a matter of PATH. – i’m confused why i’m not getting the correct path

If i log into a host  
$ echo $PATH

/opt/krb5/sbin/64:/usr/lib64/qt-3.3/bin:/usr/local/maven-3.2.1/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/X11R6/bin:/sbin:/usr/sbin:/usr/bin:/opt/pb/bin:/opt/perf/bin:/bin:/usr/local/bin:/home/corcharp/bin

But from ANSIBLE  
$ ansible all -i myhosts2 -m shell -a ‘echo $PATH’  
[host1.mydom.com](http://host1.mydom.com) | SUCCESS | rc=0 \>\>  
/usr/lib64/qt-3.3/bin:/usr/local/maven-3.2.1/bin:/usr/local/bin:/bin:/usr/bin

In my cfg, i have executable=/bin/bash

---

<div class="post-metadata">

**Author:** ![Benjamin\_Redling](https://avatars.discourse-cdn.com/v4/letter/b/47e85d/32.png) [@Benjamin\_Redling](https://forum.ansible.com/u/Benjamin_Redling)\
**Post date:** [April 4, 2016, 6:15pm UTC](https://forum.ansible.com/t/help-problem-with-become-and-pbrun/21044/5 "2016-04-04T18:15:44Z")

</div>

login vs non-login shell?

[http://stackoverflow.com/questions/27733511/how-to-set-linux-environment-variables-with-ansible](http://stackoverflow.com/questions/27733511/how-to-set-linux-environment-variables-with-ansible)

Benjamin

---

<div class="post-metadata">

**Author:** ![phillip.corchary](https://avatars.discourse-cdn.com/v4/letter/p/eada6e/32.png) [@phillip.corchary](https://forum.ansible.com/u/phillip.corchary)\
**Post date:** [April 4, 2016, 10:30pm UTC](https://forum.ansible.com/t/help-problem-with-become-and-pbrun/21044/6 "2016-04-04T22:30:47Z")

</div>

Interesting. I was not aware of this : \<\<_Consider adding those environment variables in the .bashrc file. I guess the reason behind this is the login and the non-login shells .Ansible, while executing different tasks reads the parameters from a .bashrc file instead of the bash\_profile or the /etc/profile._\>\>

so, I tried on just one host to add the absolute path i need in my $HOME/.bashrc, but still it is not working … I’m not very familiar with pbrun, and I’m not allowed to change the pbrun installation or configuration in any way in this environment.

$ ansible all -i myhosts2 -m shell -a ‘echo $PATH’  
[host1.mydom.com](http://host1.mydom.com) | SUCCESS | rc=0 \>\>  
/usr/lib64/qt-3.3/bin:/usr/local/maven-3.2.1/bin:/usr/local/bin:/bin:/usr/bin:/opt/pb/bin

$ ansible all -i myhosts2 -o -m shell -a ‘uptime’ -b --become-method pbrun  
[host1.mydom.com](http://host1.mydom.com) | FAILED! =\> {“changed”: false, “failed”: true, “module\_stderr”: “”, “module\_stdout”: “usage: pbrun [-D level] -h | -K | -k | -V\r\nusage: pbrun -v [-AknS] [-D level] [-g groupname|#gid] [-p prompt] [-u user\r\n name|#uid]\r\nusage: pbrun -l[l] [-AknS] [-D level] [-g groupname|#gid] [-p prompt] [-U user\r\n name] [-u user name|#uid] [-g groupname|#gid] [command]\r\nusage: pbrun [-AbEHknPS] [-r role] [-t type] [-C fd] [-D level] [-g\r\n groupname|#gid] [-p prompt] [-u user name|#uid] [-g\r\n groupname|#gid] [VAR=value] [-i|-s] []\r\nusage: pbrun -e [-AknS] [-r role] [-t type] [-C fd] [-D level] [-g\r\n groupname|#gid] [-p prompt] [-u user name|#uid] file …\r\n”, “msg”: “MODULE FAILURE”, “parsed”: false}

$ pbrun -V  
Sudo version 1.8.6p3  
Sudoers policy plugin version 1.8.6p3  
Sudoers file grammar version 42  
Sudoers I/O plugin version 1.8.6p3

---

<div class="post-metadata">

**Author:** ![Benjamin\_Redling](https://avatars.discourse-cdn.com/v4/letter/b/47e85d/32.png) [@Benjamin\_Redling](https://forum.ansible.com/u/Benjamin_Redling)\
**Post date:** [April 5, 2016, 1:35pm UTC](https://forum.ansible.com/t/help-problem-with-become-and-pbrun/21044/7 "2016-04-05T13:35:23Z")

</div>

Maybe you shouldn't depend on the remote users environment and set the  
important stuff explicitly:  
[http://docs.ansible.com/ansible/playbooks\_environment.html](http://docs.ansible.com/ansible/playbooks_environment.html)

Benjamin

---

<div class="post-metadata">

**Author:** ![Jonathan\_Davila](https://avatars.discourse-cdn.com/v4/letter/j/e0b2c6/32.png) [@Jonathan\_Davila](https://forum.ansible.com/u/Jonathan_Davila)\
**Post date:** [April 5, 2016, 2:02pm UTC](https://forum.ansible.com/t/help-problem-with-become-and-pbrun/21044/8 "2016-04-05T14:02:36Z")

</div>

It looks like your recent run found pbrun. I recently worked with a client that used pbrun and here’s a brief walkthrough of what they did to fix it. Also, could you retry via a playbook (not ad hoc) and add -vvvv to the run.
