# Ansible Inventory and http\_proxy environment variables

**URL:** <https://forum.ansible.com/t/ansible-inventory-and-http-proxy-environment-variables/29067>\
**Category:** Ansible Project\
**Created:** [November 19, 2018, 5:41pm UTC](https://forum.ansible.com/t/ansible-inventory-and-http-proxy-environment-variables/29067 "2018-11-19T17:41:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bruno\_Cochofel](https://avatars.discourse-cdn.com/v4/letter/b/4da419/32.png) [@Bruno\_Cochofel](https://forum.ansible.com/u/Bruno_Cochofel)\
**Post date:** [November 19, 2018, 5:41pm UTC](https://forum.ansible.com/t/ansible-inventory-and-http-proxy-environment-variables/29067/1 "2018-11-19T17:41:46Z")

</div>

Hi,

I have more then one DC, one with proxy and the other with no proxy. Almost all my servers are on the DC that has proxy.  
Can I set something like (taken from ansible documentation):

```auto
---
# file: group_vars/boston

ntp_server: ntp.bos.example.com
backup: bak.bos.example.com
proxy_env:
  http_proxy: http://proxy.bos.example.com:8080
  https_proxy: http://proxy.bos.example.com:8080

```

```auto
and use

```

```auto
environment: "{{proxy_env}}"

```

```auto
but for the other hosts undefined/unset the proxy_env and don't use the "environment"?

```

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [November 19, 2018, 6:13pm UTC](https://forum.ansible.com/t/ansible-inventory-and-http-proxy-environment-variables/29067/2 "2018-11-19T18:13:41Z")

</div>

I think this should work, in group\_vars/all set proxy\_env to empty dict so you don't get undefined variable.  
proxy\_env: {}

Then you can set proxy\_env to a proper value in the group\_vars or host\_vars depending on your requirement.

---

<div class="post-metadata">

**Author:** ![Bruno\_Cochofel](https://avatars.discourse-cdn.com/v4/letter/b/4da419/32.png) [@Bruno\_Cochofel](https://forum.ansible.com/u/Bruno_Cochofel)\
**Post date:** [November 20, 2018, 9:10am UTC](https://forum.ansible.com/t/ansible-inventory-and-http-proxy-environment-variables/29067/3 "2018-11-20T09:10:25Z")

</div>

Thanks Kai, I’ll give it a try.

---

<div class="post-metadata">

**Author:** ![Bruno\_Cochofel](https://avatars.discourse-cdn.com/v4/letter/b/4da419/32.png) [@Bruno\_Cochofel](https://forum.ansible.com/u/Bruno_Cochofel)\
**Post date:** [November 20, 2018, 9:54am UTC](https://forum.ansible.com/t/ansible-inventory-and-http-proxy-environment-variables/29067/4 "2018-11-20T09:54:02Z")

</div>

Hi,

That works 🙂
