# Help with conditional for environment variables

**URL:** <https://forum.ansible.com/t/help-with-conditional-for-environment-variables/19291>\
**Category:** Ansible Project\
**Created:** [September 17, 2015, 6:07pm UTC](https://forum.ansible.com/t/help-with-conditional-for-environment-variables/19291 "2015-09-17T18:07:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alejandro](https://avatars.discourse-cdn.com/v4/letter/a/ee7513/32.png) [@Alejandro](https://forum.ansible.com/u/Alejandro)\
**Post date:** [September 17, 2015, 6:07pm UTC](https://forum.ansible.com/t/help-with-conditional-for-environment-variables/19291/1 "2015-09-17T18:07:51Z")

</div>

Hi,

I has a common roles, where I install all base packages.

Now we has some environments where need proxy and others where is not needed.

> - name: Epel repo OracleLinux  
> yum: name=[http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm](http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm) state=present  
> when: ansible\_distribution == ‘OracleLinux’  
> environment: proxy\_env

Some way to add

> environment: proxy\_env

just in some cases?

Thanks!  
Ale

---

<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:** [September 21, 2015, 7:40pm UTC](https://forum.ansible.com/t/help-with-conditional-for-environment-variables/19291/2 "2015-09-21T19:40:12Z")

</div>

set diff versions proxy\_env in group\_vars/{has\_env1,has\_no\_env} so  
each group will get the environment they need

also use like:

environment: "{{proxy\_env}}"

for the empty you can set:

proxy\_env: {}
