# get\_url: Request failed: \<urlopen error (101, 'Network is unreachable')

**URL:** <https://forum.ansible.com/t/get-url-request-failed-urlopen-error-101-network-is-unreachable/16850>\
**Category:** Ansible Project\
**Created:** [November 21, 2014, 6:13pm UTC](https://forum.ansible.com/t/get-url-request-failed-urlopen-error-101-network-is-unreachable/16850 "2014-11-21T18:13:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![diana\_h](https://avatars.discourse-cdn.com/v4/letter/d/b5e925/32.png) [@diana\_h](https://forum.ansible.com/u/diana_h)\
**Post date:** [November 21, 2014, 6:13pm UTC](https://forum.ansible.com/t/get-url-request-failed-urlopen-error-101-network-is-unreachable/16850/1 "2014-11-21T18:13:00Z")

</div>

Hi All,

I tried to use get\_url in playbook.yml to download Elasticsearch package =\> failed.  
But it is OK for me to use wget to download the package.  
What should I do to get get\_url works in ansible playbook?

My env: ansible v1.7.2, running on CentOS release 5.8

[vagrant@machine2]$ ansible-playbook /vagrant/provisioning/playbook.yml --inventory-file=/tmp/ansible\_hosts --extra-vars “is\_windows=true” --connection=local

PLAY [Configure Instance(s)] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

GATHERING FACTS \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [192.168.33.110]

TASK: [install jdk 1.7] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [192.168.33.110]

TASK: [Download Elasticsearch package] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

failed: [192.168.33.110] =\> {“dest”: “/root/elasticsearch-1.4.0.tar.gz”, “failed”: true, “response”: “Request failed: \<urlopen error (101, ‘Network is unreachable’)\>”, “state”: “absent”, “status\_code”: -1, “url”: “[http://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.4.0.tar.gz](http://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.4.0.tar.gz)”}  
msg: Request failed

FATAL: all hosts have already failed – aborting

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
to retry, use: --limit @/home/vagrant/playbook.retry

192.168.33.110 : ok=2 changed=0 unreachable=0 failed=1

[vagrant@machine2 etc]$

---------------- my ansible: playbook.yml -----------------------------------

- name: Configure Instance(s)  
hosts: all  
sudo: yes  
gather\_facts: true

tags:

- config
- configure

tasks:

- name: install jdk 1.7  
yum: pkg=java-1.7.0-openjdk state=installed

- name: Download Elasticsearch package  
get\_url: url= **http** ://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.4.0.tar.gz dest=~/elasticsearch-1.4.0.tar.gz

------------------------------------------ wget works --------------

[vagrant@machine2 src]$ wget [http://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.4.0.tar.gz](http://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.4.0.tar.gz)  
–2014-11-19 21:29:49-- [http://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.4.0.tar.gz](http://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.4.0.tar.gz)  
Resolving corp-proxy.mhc… 152.159.215.21  
Connecting to corp-proxy.mhc|152.159.215.21|:8080… connected.  
Proxy request sent, awaiting response… 200 OK  
Length: 27730896 (26M) [application/x-tar]  
Saving to: `elasticsearch-1.4.0.tar.gz.1’

100%[======================================\>] 27,730,896 5.71M/s in 5.5s

2014-11-19 21:29:54 (4.82 MB/s) - `elasticsearch-1.4.0.tar.gz.1’ saved [27730896/27730896]

[vagrant@machine2 src]$

Thanks in advance for your help.  
Diana

---

<div class="post-metadata">

**Author:** ![James\_Martin1](https://avatars.discourse-cdn.com/v4/letter/j/0ea827/32.png) [@James\_Martin1](https://forum.ansible.com/u/James_Martin1)\
**Post date:** [November 21, 2014, 8:09pm UTC](https://forum.ansible.com/t/get-url-request-failed-urlopen-error-101-network-is-unreachable/16850/2 "2014-11-21T20:09:15Z")

</div>

Are you using an http proxy by chance?

export |grep -i proxy

If so, you’ll need to tell ansible to use it. Ansible won’t inherit environment variables by default. Check this link to learn about using proxies with Ansible if that is the case.

[http://docs.ansible.com/playbooks\_environment.html](http://docs.ansible.com/playbooks_environment.html)

- James

---

<div class="post-metadata">

**Author:** ![diana\_h](https://avatars.discourse-cdn.com/v4/letter/d/b5e925/32.png) [@diana\_h](https://forum.ansible.com/u/diana_h)\
**Post date:** [November 21, 2014, 9:13pm UTC](https://forum.ansible.com/t/get-url-request-failed-urlopen-error-101-network-is-unreachable/16850/3 "2014-11-21T21:13:58Z")

</div>

Hi James,

Thanks for your answer that “Ansible won’t inherit environment variable by default”  
And I will try to use ansible the ‘environment’ keyword to configure the http\_proxy setting. Thanks a lot!

Diana
