environment proxy variable not working

9 views
Skip to first unread message

Chris Bidwell - NOAA Federal

unread,
Jul 17, 2020, 12:53:43 PM7/17/20
to ansible...@googlegroups.com
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: http://proxy:8080


Here is it being used in my playbook:

  tasks:
    - name: check if repo files exists
      stat:
        path: "{{ puppet5_repo }}"
      register: puppet5_exists

    - name: "Install puppet5 EL{{ os_version }}.rpm for NCS or internal networks"
      yum:
        name: "https://yum.puppetlabs.com/puppet5-release-el-{{ 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

This works.  Is there a bug somewhere in this version of ansible?  

Stefan Hornburg (Racke)

unread,
Jul 17, 2020, 1:09:42 PM7/17/20
to ansible...@googlegroups.com
On 7/17/20 6:53 PM, 'Chris Bidwell - NOAA Federal' via Ansible Project wrote:
> 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.swpc.noaa.gov:8080>
>       http_proxy: http://proxy: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: "Install puppet5 EL{{ os_version }}.rpm for NCS or internal networks"
>       yum:
>         name: "https://yum.puppetlabs.com/puppet5-release-el-{{ <https://yum.puppetlabs.com/puppet5-release-el-%7B%7B>
> 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
>
> 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
Racke

>
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
> ansible-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAHKi8CiZbvkUKQBwYdM4ejdPxPvJ9FObLR%3DNi2XVy%2BcSx74sAg%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CAHKi8CiZbvkUKQBwYdM4ejdPxPvJ9FObLR%3DNi2XVy%2BcSx74sAg%40mail.gmail.com?utm_medium=email&utm_source=footer>.


--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.

signature.asc

Chris Bidwell - NOAA Federal

unread,
Jul 17, 2020, 1:55:10 PM7/17/20
to ansible...@googlegroups.com
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.
<corona-lx> 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 /usr/libexec/platform-python /home/tsg/.ansible/tmp/ansible-tmp-1595008297.67-12298-28530305002590/AnsiballZ_dnf.py'"'"'"'"'"'"'"'"' && sleep 0'"'"''
Escalation succeeded




To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/702e6c53-1d70-19c5-2b3a-17a38e7dba50%40linuxia.de.
Reply all
Reply to author
Forward
0 new messages