# The default flags passed to sudo sudo\_flags=-Hi

**URL:** <https://forum.ansible.com/t/the-default-flags-passed-to-sudo-sudo-flags-hi/12302>\
**Category:** Ansible Project\
**Created:** [February 7, 2013, 8:57am UTC](https://forum.ansible.com/t/the-default-flags-passed-to-sudo-sudo-flags-hi/12302 "2013-02-07T08:57:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mark\_Maas](https://avatars.discourse-cdn.com/v4/letter/m/7c8e57/32.png) [@Mark\_Maas](https://forum.ansible.com/u/Mark_Maas)\
**Post date:** [February 7, 2013, 8:57am UTC](https://forum.ansible.com/t/the-default-flags-passed-to-sudo-sudo-flags-hi/12302/1 "2013-02-07T08:57:15Z")

</div>

Hi List,

I’m trying to add the “-i” sudo option to the sudo\_flags= configuration option in the ansible.cfg like so:

> # the default flags passed to sudo
> 
> sudo\_flags=-Hi

This is because I want some things to run under the oracle user in my playbook, meaning it needs it’s environment set properly (Like ORACLE\_HOME)

But when I add the option, ansible does not even go past “GATHERING FACTS”:

> mmaas@xmgtansible:~/playbooks$ ansible-playbook binck/site.yml --extra-vars hosts=t2wwwkripke --tags=users-dba -vvvvv
> 
> sudo password:
> 
> PLAY [t2wwwkripke] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
> 
> GATHERING FACTS \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
> 
> ESTABLISH CONNECTION FOR USER: mmaas on PORT 22 TO t2wwwkripke
> 
> EXEC /bin/sh -c ‘mkdir -p $HOME/.ansible/tmp/ansible-1360227274.82-278808592316494 && chmod a+rx $HOME/.ansible/tmp/ansible-1360227274.82-278808592316494 && echo $HOME/.ansible/tmp/ansible-1360227274.82-278808592316494’
> 
> REMOTE\_MODULE setup
> 
> PUT /tmp/tmp4SHl9r TO /home/mmaas/.ansible/tmp/ansible-1360227274.82-278808592316494/setup
> 
> EXEC /bin/sh -c ‘sudo -k && sudo -Hi -S -p “[sudo via ansible, key=ijizcovnimrhdctfmrswznnvqgfpibhz] password: " -u root /bin/sh -c '”’“‘/usr/bin/python /home/mmaas/.ansible/tmp/ansible-1360227274.82-278808592316494/setup; rm -rf /home/mmaas/.ansible/tmp/ansible-1360227274.82-278808592316494/ \>/dev/null 2\>&1’”‘"’’

At that point I have to CTRL-c to stop the playbook run.  
The ansible version is 1.1

Any suggestions? Thanks!

---

<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:** [February 7, 2013, 12:41pm UTC](https://forum.ansible.com/t/the-default-flags-passed-to-sudo-sudo-flags-hi/12302/2 "2013-02-07T12:41:07Z")

</div>

I believe sudo "-i" tends to cause problems.

"-H", however should be good to go.

I'm going to be adding some features very very very very soon to allow  
environments to get set in commands for specific variables that should  
resolve this issue  
very well.

Until then, a workaround may be to use the command module in a few  
places. This is suboptimal, but will work.

ETA is probably a week or two, adding the environment feature is  
actually going to be pretty easy for us, and will also enable some  
other things.

Ticket is already open (talking about proxies)

---

<div class="post-metadata">

**Author:** ![Mark\_Maas](https://avatars.discourse-cdn.com/v4/letter/m/7c8e57/32.png) [@Mark\_Maas](https://forum.ansible.com/u/Mark_Maas)\
**Post date:** [February 7, 2013, 5:49pm UTC](https://forum.ansible.com/t/the-default-flags-passed-to-sudo-sudo-flags-hi/12302/3 "2013-02-07T17:49:48Z")

</div>

Soo basicly you read my mind?! 😉  
Awesome, looking forward to the next update then.

And I did not know that the command module already loads the environment, good stuff!

---

<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:** [February 7, 2013, 6:17pm UTC](https://forum.ansible.com/t/the-default-flags-passed-to-sudo-sudo-flags-hi/12302/4 "2013-02-07T18:17:08Z")

</div>

> Soo basicly you read my mind?! 😉  
> Awesome, looking forward to the next update then.
> 
> And I did not know that the command module already loads the environment,  
> good stuff!

shell one should at least?

anyway, I was thinking like this:

shell: ORACLE\_HOME=$splat oracle-command-here --some-arguments=1234

which I'm going to add like

shell: ...  
environment: $environment

where $environment is either a variable that is a hash, or a hash.
