On 8/25/20 5:39 PM, Ingrum Jefferson wrote:
> 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

> 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', wantlist=True) 
> }}"
> - 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') }}"
> - name: url lookup using headers
>   debug: msg="{{ lookup('url', '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:
> ---
>   - name:  Web Printers
>   - hosts:
>     - printers
>     - uri:
>     -  url:
>         - http://{{ item }}/
>         - return_content:
>            - yes
>        register: webpage
>        with_items:
>        - "{{ groups['printers'] }}"
> 
> Results:
> 
> the full traceback was:
> Traceback (most recent call last):
>   File "/usr/bin/ansible-playbook", line 123, in <module>
>     exit_code = cli.run()
>   File "/usr/lib/python2.7/site-packages/ansible/cli/playbook.py", line 127, 
> in run
>     results = pbex.run()
>   File 
> "/usr/lib/python2.7/site-packages/ansible/executor/playbook_executor.py", 
> line 91, in run
>     pb = Playbook.load(playbook_path, 
> variable_manager=self._variable_manager, loader=self._loader)
>   File "/usr/lib/python2.7/site-packages/ansible/playbook/__init__.py", line 
> 51, in load
>     pb._load_playbook_data(file_name=file_name, 
> variable_manager=variable_manager)
>   File "/usr/lib/python2.7/site-packages/ansible/playbook/__init__.py", line 
> 103, in _load_playbook_data
>     entry_obj = Play.load(entry, variable_manager=variable_manager, 
> loader=self._loader, vars=vars)
>   File "/usr/lib/python2.7/site-packages/ansible/playbook/play.py", line 110, 
> in load
>     data['name'] = ','.join(data['hosts'])
> TypeError: sequence item 1: expected string or Unicode, AnsibleMapping found
> 
> 
> Someone please respond quickly.
> 
> 
> Thank you,
> 
> Jeff
> 
> -- 
> 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-project+unsubscr...@googlegroups.com 
> <mailto:ansible-project+unsubscr...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/11a18812-b505-49e9-942d-9c2b7f51a85cn%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/11a18812-b505-49e9-942d-9c2b7f51a85cn%40googlegroups.com?utm_medium=email&utm_source=footer>.


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

-- 
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-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/6d4fc243-f0c8-e525-9325-d1df09130aec%40linuxia.de.

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to