# Does apt\_key use proxy environment vars?

**URL:** <https://forum.ansible.com/t/does-apt-key-use-proxy-environment-vars/17774>\
**Category:** Ansible Project\
**Created:** [March 18, 2015, 3:21pm UTC](https://forum.ansible.com/t/does-apt-key-use-proxy-environment-vars/17774 "2015-03-18T15:21:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jon\_Soul](https://avatars.discourse-cdn.com/v4/letter/j/ecc23a/32.png) [@Jon\_Soul](https://forum.ansible.com/u/Jon_Soul)\
**Post date:** [March 18, 2015, 3:21pm UTC](https://forum.ansible.com/t/does-apt-key-use-proxy-environment-vars/17774/1 "2015-03-18T15:21:43Z")

</div>

I’m using a role in my playbook that uses the apt\_key module:

`

- name: import repository key  
`  
apt\_key: url=[http://www.rabbitmq.com/rabbitmq-signing-key-public.asc](http://www.rabbitmq.com/rabbitmq-signing-key-public.asc) state=present

The target host sits behind a proxy, and I have the usual proxy environment variables already set. This is enough to get various apt, apt\_repository and other external-resource-calling tasks to work without a problem. However apt\_key fails:

> msg: Failed to download key at [http://www.rabbitmq.com/rabbitmq-signing-key-public.asc:](http://www.rabbitmq.com/rabbitmq-signing-key-public.asc:) Request failed:

If I explicitly set the environment proxy variables on the task then the problem is resolved (as below). Why do I explicitly have to set the environment for apt\_key and not other modules? Is this intended?

`

- name: import repository key  
apt\_key: url=[http://www.rabbitmq.com/rabbitmq-signing-key-public.asc](http://www.rabbitmq.com/rabbitmq-signing-key-public.asc) state=present  
environment:  
http\_proxy: [http://proxy.domain.com:8080](http://proxy.domain.com:8080)  
`

---

<div class="post-metadata">

**Author:** ![Jon\_Soul](https://avatars.discourse-cdn.com/v4/letter/j/ecc23a/32.png) [@Jon\_Soul](https://forum.ansible.com/u/Jon_Soul)\
**Post date:** [March 18, 2015, 3:40pm UTC](https://forum.ansible.com/t/does-apt-key-use-proxy-environment-vars/17774/2 "2015-03-18T15:40:23Z")

</div>

I’m using Ubuntu 14.04 with ansible 1.8.4

---

<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:** [March 18, 2015, 3:50pm UTC](https://forum.ansible.com/t/does-apt-key-use-proxy-environment-vars/17774/3 "2015-03-18T15:50:58Z")

</div>

I looked at the code and it is the following:

os.environ.get('https\_proxy')

---

<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:** [March 18, 2015, 3:54pm UTC](https://forum.ansible.com/t/does-apt-key-use-proxy-environment-vars/17774/4 "2015-03-18T15:54:43Z")

</div>

never mind, checked all the codepaths and the module itself does not  
support proxies

---

<div class="post-metadata">

**Author:** ![Jon\_Soul](https://avatars.discourse-cdn.com/v4/letter/j/ecc23a/32.png) [@Jon\_Soul](https://forum.ansible.com/u/Jon_Soul)\
**Post date:** [March 18, 2015, 4:07pm UTC](https://forum.ansible.com/t/does-apt-key-use-proxy-environment-vars/17774/5 "2015-03-18T16:07:38Z")

</div>

Thanks for checking that out for me.

---

<div class="post-metadata">

**Author:** ![Jon\_Soul](https://avatars.discourse-cdn.com/v4/letter/j/ecc23a/32.png) [@Jon\_Soul](https://forum.ansible.com/u/Jon_Soul)\
**Post date:** [March 18, 2015, 4:58pm UTC](https://forum.ansible.com/t/does-apt-key-use-proxy-environment-vars/17774/6 "2015-03-18T16:58:44Z")

</div>

My workaround was to update to 1.9 so I could use the environment keyword at the play level.
