# URI module keeps erroring

**URL:** <https://forum.ansible.com/t/uri-module-keeps-erroring/33671>\
**Category:** Ansible Project\
**Created:** [August 25, 2020, 3:39pm UTC](https://forum.ansible.com/t/uri-module-keeps-erroring/33671 "2020-08-25T15:39:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ingrum\_Jefferson1](https://avatars.discourse-cdn.com/v4/letter/i/b5ac83/32.png) [@Ingrum\_Jefferson1](https://forum.ansible.com/u/Ingrum_Jefferson1)\
**Post date:** [August 25, 2020, 3:39pm UTC](https://forum.ansible.com/t/uri-module-keeps-erroring/33671/1 "2020-08-25T15:39:35Z")

</div>

Hi Group,

I have been stuck for a few days on this issue; I am not sure whether it is a defect or not.

I am running Ansible version 2,9.6. I am able to run any playbook using the ssh and Linux module. However when I attempt to make a simple connection to a website using the URI module, it errors. even though the formatting and indentation is correct.

I am using this example code I found on the Internet:

- name: url lookup splits lines by default
- hosts: all  
tasks:  
debug: msg=“{{item}}”  
loop: “{{ lookup(‘url’, ‘[https://github.com/gremlin.keys](https://github.com/gremlin.keys)’, wantlist=True) }}”
- name: display ip ranges  
debug: msg=“{{ lookup(‘url’, ‘[https://ip-ranges.amazonaws.com/ip-ranges.json](https://ip-ranges.amazonaws.com/ip-ranges.json)’, split\_lines=False) }}”
- name: url lookup using authentication  
debug: msg=“{{ lookup(‘url’, ‘[https://some.private.site.com/file.txt](https://some.private.site.com/file.txt)’, username=‘bob’, password=‘hunter2’) }}”
- name: url lookup using headers  
debug: msg=“{{ lookup(‘url’, ‘[https://some.private.site.com/api/service](https://some.private.site.com/api/service)’, headers={‘header1’:‘value1’, ‘header2’:‘value2’} ) }}”

yamlchecker,com confirmed the format.

the following is the error that I keep getting, I have also used other code examples, see below, see debug error:

ansible-playbook 2.9.6  
config file = /etc/ansible/ansible.cfg  
configured module search path = [u’/root/.ansible/plugins/modules’, u’/usr/share/ansible/plugins/modules’]  
ansible python module location = /usr/lib/python2.7/site-packages/ansible  
executable location = /usr/bin/ansible-playbook  
python version = 2.7.5 (default, Aug 7 2019, 00:51:29) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]  
Using /etc/ansible/ansible.cfg as config file  
host\_list declined parsing /root/inventory as it did not pass its verify\_file() method  
script declined parsing /root/inventory as it did not pass its verify\_file() method  
auto declined parsing /root/inventory as it did not pass its verify\_file() method  
Parsed /root/inventory inventory source with ini plugin  
**ERROR! ‘debug’ is not a valid attribute for a Play**  
The error appears to be in ‘/root/webconn.yml’: line 2, column 4, but may  
be elsewhere in the file depending on the exact syntax problem.  
The offending line appears to be:

- name: url lookup splits lines by default
- hosts: all  
^ here

Another example:

---

<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:** [August 25, 2020, 3:48pm UTC](https://forum.ansible.com/t/uri-module-keeps-erroring/33671/2 "2020-08-25T15:48:29Z")

</div>

> Hi Group,
> 
> I have been stuck for a few days on this issue; I am not sure whether it is a defect or not.

Hello Ingrum,

Your playbook isn't correctly formatted, is should look like

- hosts: all  
&nbsp;&nbsp;tasks:  
&nbsp;&nbsp;&nbsp;&nbsp;- name: display ip ranges  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;debug: msg="{{ lookup('url', '[https://ip-ranges.amazonaws.com/ip-ranges.json](https://ip-ranges.amazonaws.com/ip-ranges.json)’, split\_lines=False) }}"  
&nbsp;&nbsp;&nbsp;&nbsp;- name: url lookup using authentication  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;debug: msg="{{ lookup('url', '[https://some.private.site.com/file.txt](https://some.private.site.com/file.txt)’, username='bob', password='hunter2') }}"

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

---

<div class="post-metadata">

**Author:** ![Kundan\_Singh](https://avatars.discourse-cdn.com/v4/letter/k/958977/32.png) [@Kundan\_Singh](https://forum.ansible.com/u/Kundan_Singh)\
**Post date:** [August 25, 2020, 5:32pm UTC](https://forum.ansible.com/t/uri-module-keeps-erroring/33671/3 "2020-08-25T17:32:04Z")

</div>

Hi Jeff

There is indentation error which will be validated by yaml but when you execute it  
From controller or AT it will give error

Please use below syntax

- name:  
hosts:

Regards  
Kundan singh

---

<div class="post-metadata">

**Author:** ![Ingrum\_Jefferson](https://avatars.discourse-cdn.com/v4/letter/i/4da419/32.png) [@Ingrum\_Jefferson](https://forum.ansible.com/u/Ingrum_Jefferson)\
**Post date:** [August 26, 2020, 2:11pm UTC](https://forum.ansible.com/t/uri-module-keeps-erroring/33671/4 "2020-08-26T14:11:18Z")

</div>

Thanks for getting back to me Racke; I will retest with your suggestions and report back.

Ingrum

---

<div class="post-metadata">

**Author:** ![Ingrum\_Jefferson](https://avatars.discourse-cdn.com/v4/letter/i/4da419/32.png) [@Ingrum\_Jefferson](https://forum.ansible.com/u/Ingrum_Jefferson)\
**Post date:** [August 26, 2020, 2:14pm UTC](https://forum.ansible.com/t/uri-module-keeps-erroring/33671/5 "2020-08-26T14:14:22Z")

</div>

Thank you for your response Kundan.

Ingrum
