# use of system env var

**URL:** <https://forum.ansible.com/t/use-of-system-env-var/13622>\
**Category:** Ansible Project\
**Created:** [October 7, 2013, 1:10pm UTC](https://forum.ansible.com/t/use-of-system-env-var/13622 "2013-10-07T13:10:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jean\_Philippe\_Caruan](https://avatars.discourse-cdn.com/v4/letter/j/13edae/32.png) [@Jean\_Philippe\_Caruan](https://forum.ansible.com/u/Jean_Philippe_Caruan)\
**Post date:** [October 7, 2013, 1:10pm UTC](https://forum.ansible.com/t/use-of-system-env-var/13622/1 "2013-10-07T13:10:23Z")

</div>

Hi,

I would like to use the gem module to install buildr. This gem needs to  
have an envvar defined. The command is :

sudo env JAVA\_HOME=$JAVA\_HOME gem install buildr -v 1.4.3  
(see [http://buildr.apache.org/installing.html#linux](http://buildr.apache.org/installing.html#linux))

If I don't do this, buildr refuses to install. This is usually quite a  
pain to install via the command line (easy to forget), but it becomes  
harder from ansible.

I would love to write  
-gem: name=buildr state=present JAVA\_HOME=my\_path\_to\_java\_home

Is it possible ?  
Or can I export some envvar to the sudo user before running ansible ?  
I run ansible from an unpriviledged user but I give it the sudo password  
with --ask-sudo-pass. All my tasks run with sudo: yes.

Thanks.

---

<div class="post-metadata">

**Author:** ![Brian\_Coca1](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@Brian\_Coca1](https://forum.ansible.com/u/Brian_Coca1)\
**Post date:** [October 7, 2013, 10:35pm UTC](https://forum.ansible.com/t/use-of-system-env-var/13622/2 "2013-10-07T22:35:59Z")

</div>

use the environment: keyword on the task
