Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

uri module doesn't honour environment proxy #1125

Closed
smasset opened this issue Apr 10, 2015 · 11 comments
Closed

uri module doesn't honour environment proxy #1125

smasset opened this issue Apr 10, 2015 · 11 comments

Comments

@smasset
Copy link

smasset commented Apr 10, 2015

When behind a proxy, the following uri task fails because the remote host cannot be resolved :

- name: Download from remote host behind a proxy with uri module
  sudo: yes
  uri:
    url=http://remote.host.com/remote.file
    dest=/var/tmp/remote.file
    HEADER_Cookie="name=value"
  environment: proxy_env

The following get_url task works (i.e. it resolves the host but fails to download contents as I can't set custom request header) :

- name: Download from remote host behind a proxy with get_url module
  sudo: yes
  get_url:
    url=http://remote.host.com/remote.file
    dest=/var/tmp/remote.file
  environment: proxy_env

Haven't looked at the code yet but could the uri module use the fetch_url utility method like get_url does ?

@smasset
Copy link
Author

smasset commented Apr 10, 2015

Two more bits of info :

  • I'm using ansible 1.9.0.1
  • I've used a command task with wget as a workaround

@darjeeling
Copy link

how did you setup environment: proxy_env ?
like this document you should setup http://docs.ansible.com/playbooks_environment.html or var file

      environment:
        http_proxy: http://proxy.example.com:8080

I looked at the code, IMHO the uri module well support proxy environment.
because it's using httplib2 and
it's automatically get proxy variable like http_proxy or https_proxy

https://github.com/ansible/ansible-modules-core/blob/devel/network/basics/uri.py#L262

https://github.com/jcgregorio/httplib2/blob/master/python2/httplib2/__init__.py#L804

https://github.com/jcgregorio/httplib2/blob/master/python2/httplib2/__init__.py#L1157

@smasset
Copy link
Author

smasset commented Apr 16, 2015

proxy_env is defined in a all.yml file in group_vars. Here are its values:

proxy_env:
  http_proxy: http://genproxy.domain.local:8080
  https_proxy: http://genproxy.domain.local:8080

So both modules use the same proxy configuration. I'll run the playbook again just to be sure.

@smasset
Copy link
Author

smasset commented Apr 16, 2015

Ran it again. Same result, sorry.

@kei-yamazaki
Copy link

I encountered same problem.
I'm using ansible 1.9.0.1 too.

@mstrzele
Copy link

👍

@muffl0n
Copy link
Contributor

muffl0n commented Aug 21, 2015

Same issue here with Ansible 1.9.2. When I define the proxy in the playbook it does not work for get_url. apt for example works fine!

Workaround for me is to set the proxy in /etc/environment (on Ubuntu 12/14):

    - name: add http-proxy for internal hosts
      lineinfile: dest=/etc/environment regexp="^http_proxy" line="http_proxy=\"http://usr:pwd@myproxy.company:8080\""

    - name: add https-proxy for internal hosts
      lineinfile: dest=/etc/environment regexp="^https_proxy" line="https_proxy=\"http://usr:pwd@myproxy.company:8080\""

@dieu
Copy link

dieu commented Aug 25, 2015

+1

@mstrzele
Copy link

This issue is caused by the old version of httplib2 being installed as the dependency for Ansible. Can this code be ported to the Ansible repository?

@dieu
Copy link

dieu commented Aug 25, 2015

hm, I think it's problem with timeout, I don't know foreign environment, but our proxy sometimes a long react on large files.

for me large timeout (Timeout for URL request) fixed all the problems.

@sivel
Copy link
Member

sivel commented Feb 24, 2016

This should no longer be an issue. As of 2.1 the uri module no longer has a dependency on httplib2 and will utilize the same shared code as the get_url module.

If you have further questions please stop by IRC or the mailing list:

@sivel sivel closed this as completed Feb 24, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants