# environment proxy variable not working

**URL:** <https://forum.ansible.com/t/environment-proxy-variable-not-working/33424>\
**Category:** Ansible Project\
**Created:** [July 17, 2020, 4:53pm UTC](https://forum.ansible.com/t/environment-proxy-variable-not-working/33424 "2020-07-17T16:53:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chris\_Bidwell](https://avatars.discourse-cdn.com/v4/letter/c/da6949/32.png) [@Chris\_Bidwell](https://forum.ansible.com/u/Chris_Bidwell)\
**Post date:** [July 17, 2020, 4:53pm UTC](https://forum.ansible.com/t/environment-proxy-variable-not-working/33424/1 "2020-07-17T16:53:11Z")

</div>

Hey all,

I’m having an issue trying to get ansible to use my environment variable to pull through a proxy server.

Running: ansible 2.9.10

Here’s my variable declarations:

---

<div class="post-metadata">

**Author:** ![racke](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/racke/32/4767_2.png) [@racke](https://forum.ansible.com/u/racke)\
**Post date:** [July 17, 2020, 5:08pm UTC](https://forum.ansible.com/t/environment-proxy-variable-not-working/33424/2 "2020-07-17T17:08:52Z")

</div>

> Hey all,
> 
> I'm having an issue trying to get ansible to use my environment variable to pull through a proxy server.
> 
> Running: ansible 2.9.10
> 
> Here's my variable declarations:
> 
> ---  
> - name: puppet5  
> hosts: ALL\_LINUX  
> become: yes  
> vars\_files:  
> - passwd.yml  
> - vars.yml
> 
> vars:  
> os\_version: "{{ ansible\_distribution\_major\_version }}"  
> puppet5\_repo: /etc/yum.repos.d/puppet5.repo  
> proxy\_env:  
> https\_proxy: [http://proxy:8080](http://proxy:8080) \<[http://proxy.swpc.noaa.gov:8080](http://proxy.swpc.noaa.gov:8080)\>  
> http\_proxy: [http://proxy:8080](http://proxy:8080) \<[http://proxy.swpc.noaa.gov:8080](http://proxy.swpc.noaa.gov:8080)\>
> 
> Here is it being used in my playbook:
> 
> tasks:  
> - name: check if repo files exists  
> stat:  
> path: "{{ puppet5\_repo }}"  
> register: puppet5\_exists
> 
> ```
> \- name: &quot;Install puppet5 EL\{\{ os\_version \}\}\.rpm for NCS or internal networks&quot;
> yum:
> name: &quot;https://yum.puppetlabs.com/puppet5-release-el-\{\{ &lt;https://yum.puppetlabs.com/puppet5-release-el-%7B%7B&gt;
> 
> ```
> 
> os\_version }}.noarch.rpm"  
> state: present  
> disable\_gpg\_check: yes  
> environment: "{{ proxy\_envy }}"  
> when:  
> - puppet5\_exists.stat.exists == False  
> - ansible\_default\_ipv4.address is match('192\.168\.226\.') or  
> ansible\_default\_ipv4.address is match('192\.168\.223\.')
> 
> Notice that the URL I'm trying to pull is https. When I run the playbook, it's defaulting to http. If I hard code the  
> environment with:
> 
> environment:  
> - https\_proxy: [http://proxy:8080](http://proxy:8080)
> 
> This works. Is there a bug somewhere in this version of ansible?

Is the name of the variable proxy\_envy a typo in your playbook?

Regards  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Racke

---

<div class="post-metadata">

**Author:** ![Chris\_Bidwell](https://avatars.discourse-cdn.com/v4/letter/c/da6949/32.png) [@Chris\_Bidwell](https://forum.ansible.com/u/Chris_Bidwell)\
**Post date:** [July 17, 2020, 5:54pm UTC](https://forum.ansible.com/t/environment-proxy-variable-not-working/33424/3 "2020-07-17T17:54:39Z")

</div>

Interesting. That must have been my own typo.

I’ve verified that my variable name says proxy\_env on both the declaration and where it’s trying to be applied to.

Here’s the verbose output – it keeps trying to use the http\_proxy instead of the https\_proxy.  
 **SSH: EXEC sshpass -d10 ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o ‘User=“tsg”’ -o ConnectTimeout=90 -o ControlPath=/home/chris.bidwell/.ansible/cp/84c0dc074e -tt corona-lx ‘/bin/sh -c ‘"’“'sudo -H -S -p “[sudo via ansible, key=roxxdufstmkkexijnydloqgrgbewanlx] password:” -u root /bin/sh -c '”’“'”‘"’“'”‘"’“‘echo BECOME-SUCCESS-roxxdufstmkkexijnydloqgrgbewanlx ; http\_proxy=[http://proxy:8080](http://proxy:8080) /usr/libexec/platform-python /home/tsg/.ansible/tmp/ansible-tmp-1595008297.67-12298-28530305002590/AnsiballZ\_dnf.py’”‘"’“'”‘"’“'”‘"’ && sleep 0’“'”‘’**  
**Escalation succeeded**
