URI module keeps erroring

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:

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:

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
  tasks:
    - name: display ip ranges
      debug: msg="{{ lookup('url', '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’, username='bob', password='hunter2') }}"

Regards
        Racke

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

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

Ingrum

Thank you for your response Kundan.

Ingrum