# Ansible Sudo Issue-Solaris

**URL:** <https://forum.ansible.com/t/ansible-sudo-issue-solaris/28834>\
**Category:** Ansible Project\
**Created:** [October 20, 2018, 7:47am UTC](https://forum.ansible.com/t/ansible-sudo-issue-solaris/28834 "2018-10-20T07:47:41Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bairava\_Surya](https://avatars.discourse-cdn.com/v4/letter/b/f1d935/32.png) [@Bairava\_Surya](https://forum.ansible.com/u/Bairava_Surya)\
**Post date:** [October 20, 2018, 7:47am UTC](https://forum.ansible.com/t/ansible-sudo-issue-solaris/28834/1 "2018-10-20T07:47:41Z")

</div>

hi all,

i want to run basic command on solaris OS i.e whoami using become command.so am able to sudo to different user using putty successfully but facing issues via ansible.

OS:solaris  
Sudo user:mygroup  
sudo implementation:.usr/local/bin/sudo su - mygroup  
Authentication:QAS(VAS)

Error:

fatal: [mahcine]: FAILED! =\> {“changed”: false, “module\_stderr”: “Shared connection to machineclosed.\r\n”, “module\_stdout”: “/bin/sh: sudo:  
not found\r\n”, “msg”: “MODULE FAILURE”, “rc”: 1}

can anyone guide me what changes i need to make inorder to get output as **mygroup**

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [October 20, 2018, 6:06pm UTC](https://forum.ansible.com/t/ansible-sudo-issue-solaris/28834/2 "2018-10-20T18:06:54Z")

</div>

Hi  
In order to help we need the actual playbook or task that generates this (erroneous) output. So please provide that.

Also, your mentioning of ‘basic command whoami using become command’ indicates that you might be using a wrong approach.  
So also tell us what you’re actually trying to achieve on the target system.

Dick

---

<div class="post-metadata">

**Author:** ![Bairava\_Surya](https://avatars.discourse-cdn.com/v4/letter/b/f1d935/32.png) [@Bairava\_Surya](https://forum.ansible.com/u/Bairava_Surya)\
**Post date:** [October 25, 2018, 1:36pm UTC](https://forum.ansible.com/t/ansible-sudo-issue-solaris/28834/3 "2018-10-25T13:36:33Z")

</div>

hi Visser,

please find the below playbook and let me know any changes to be made

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [October 28, 2018, 9:16pm UTC](https://forum.ansible.com/t/ansible-sudo-issue-solaris/28834/4 "2018-10-28T21:16:22Z")

</div>

Hi Bairava

If this playbook would work, it would basically become a user, run  
whoami, and the output would be the same as you told it to become.  
Which I why I asked, please tell \*what you are trying to achieve\* on  
the target system.  
And by that I mean the real \*end goal\* - not that fact that you are  
trying to figure out what user a null playbook is running at.  
FYI, you're supposed to supply this information to ansible - not ask for it.  
Despite the playbook not being very useful, one issue can be spot, and  
that is that you configure the become\_method as 'sudo' (which is the  
default btw), but the error you got indicates that there is no sudo  
command on the target system. So it looks like the concept of  
privilege escalation is not totally clear, you might find it helpful  
to read [https://docs.ansible.com/ansible/latest/user\_guide/become.html](https://docs.ansible.com/ansible/latest/user_guide/become.html).

Dick

---

<div class="post-metadata">

**Author:** ![Bairava\_Surya](https://avatars.discourse-cdn.com/v4/letter/b/f1d935/32.png) [@Bairava\_Surya](https://forum.ansible.com/u/Bairava_Surya)\
**Post date:** [October 29, 2018, 2:09pm UTC](https://forum.ansible.com/t/ansible-sudo-issue-solaris/28834/5 "2018-10-29T14:09:18Z")

</div>

Hi Visser

I just configured sudo\_exe=/usr/local/bin/sudo su - sudousername in ansible.cfg now am getting timeout error as it expects AD account password.

In Solaris machine which is my target machine it uses QAS authentication service so when we login into machine using putty software we will login two stepsi.e first step as ssh into solaris via our username,password and second step enter sudo to other user by entering password so finally we are entering two times password which we are trying it in ansible.

My end goal is to sudo to target machine.

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [October 29, 2018, 3:58pm UTC](https://forum.ansible.com/t/ansible-sudo-issue-solaris/28834/6 "2018-10-29T15:58:50Z")

</div>

You keep mixing up things here.  
By "end goal" I meant really a target situation, whereby something is  
changed/configured.  
Just "sudo to target machine" doesn't make sense.

You SSH \*to\* a machine. And then you run a command, or a series of  
commands, etc.  
This is what ansible can automate for you.  
Since most commands require elevated privileges, some ways to do that  
are available when you're on the machine.  
For instance sudo. Which optionally requires a username to sudo to  
(default root). And optionally a password.

But all of this is done to run some useful task/program.  
This is what you still have not told yet.  
The new thread you started has yet again a confusing and insecure  
playbook to find out what username you are using.

So can you please share what you are trying to achieve?  
Since this appears to not be clear, here are some examples of what  
Ansible is usually used for:

\* Make sure a package is installed  
\* Make sure a configuration file is available  
\* Make sure a directory/file structure exists

Thanks!

Dick

---

<div class="post-metadata">

**Author:** ![Bairava\_Surya](https://avatars.discourse-cdn.com/v4/letter/b/f1d935/32.png) [@Bairava\_Surya](https://forum.ansible.com/u/Bairava_Surya)\
**Post date:** [October 30, 2018, 8:49am UTC](https://forum.ansible.com/t/ansible-sudo-issue-solaris/28834/7 "2018-10-30T08:49:23Z")

</div>

Hi Visser,

Let me explain each and every step.

With our solaris box so generally we try to login as our user by entering username and password and again we run sudo command to other user by entering password.  
So here sudo expects password in interactively prompt way so how we can achieve this using ansible.

---

<div class="post-metadata">

**Author:** ![Bairava\_Surya](https://avatars.discourse-cdn.com/v4/letter/b/f1d935/32.png) [@Bairava\_Surya](https://forum.ansible.com/u/Bairava_Surya)\
**Post date:** [October 30, 2018, 5:15pm UTC](https://forum.ansible.com/t/ansible-sudo-issue-solaris/28834/8 "2018-10-30T17:15:14Z")

</div>

Adding more logs to understand the issue.

ESTABLISH SSH CONNECTION FOR USER: xxxx  
 SSH: EXEC sshpass -d12 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o U  
ser=xxxx -o ConnectTimeout=10 -o ControlPath=/home/vagrant/.ansible/cp/305901ab16 nj12mhf5685 ‘/bin/sh -c ’  
"’“‘chmod a+rx /var/tmp/ansible-tmp-1540918785.12-245644937797326/ /var/tmp/ansible-tmp-1540918785.12-245644937797326/se  
tup.py && sleep 0’”‘"’’  
 (0, ‘’, ‘’)  
 ESTABLISH SSH CONNECTION FOR USER:xxxx  
 SSH: EXEC sshpass -d12 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o U  
ser=surya\_subramanian -o ConnectTimeout=10 -o ControlPath=/home/vagrant/.ansible/cp/305901ab16 -tt nj12mhf5685 ‘/bin/sh  
-c ‘"’"’/usr/local/bin/sudo su -p “[sudo via ansible, key=mkqlqucvkvgamlynmqitnoknuevmiges] password: " -u wlsrghf /bin  
/sh -c '”‘"’“'”‘"’“'”‘“‘echo BECOME-SUCCESS-mkqlqucvkvgamlynmqitnoknuevmiges; /usr/bin/python /var/tmp/ansible-tmp-15409  
18785.12-245644937797326/setup.py’”’“'”‘"’“'”‘"’“’ && sleep 0’”‘"’’  
fatal: [server]: FAILED! =\> {  
“msg”: "Timeout (12s) waiting for privilege escalation prompt: "  
}  
to retry, use: --limit @/home/vagrant/ansible-mysudo-imple/ansible-Sudo/rg\_repo/server\_control.retry

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

Am facing above issue when am executing using become module.can anyone help me on it as i tried multiple approach to fix it.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [October 30, 2018, 6:05pm UTC](https://forum.ansible.com/t/ansible-sudo-issue-solaris/28834/9 "2018-10-30T18:05:11Z")

</div>

this is a problem `'/usr/local/bin/sudo su -p ` as 'su' does not take  
-p parameter for prompting, its for 'preserve environment', you are  
mixing privilege escalation tools and that is something that is not  
supported by Ansible itself.  
[https://docs.ansible.com/ansible/latest/user\_guide/become.html](https://docs.ansible.com/ansible/latest/user_guide/become.html)

---

<div class="post-metadata">

**Author:** ![cyril\_thankappan](https://avatars.discourse-cdn.com/v4/letter/c/58956e/32.png) [@cyril\_thankappan](https://forum.ansible.com/u/cyril_thankappan)\
**Post date:** [October 30, 2018, 6:52pm UTC](https://forum.ansible.com/t/ansible-sudo-issue-solaris/28834/10 "2018-10-30T18:52:22Z")

</div>

Hi All

I am also facing similar issues with pbrun

Trying to find more details on the workaround in  
[https://github.com/ansible/ansible/issues/14934](https://github.com/ansible/ansible/issues/14934)

Thanks

Cyril
