ansible.builtin.url (v2.9.13) — lookup

return contents from URL

| "added in version" 1.9 of ansible.builtin"

Authors: Brian Coca (@bcoca)

Install Ansible via pip

Install with pip install ansible==2.9.13

Description

Returns the content of the URL requested to be used as data in play.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: url lookup splits lines by default
  debug: msg="{{item}}"
  loop: "{{ lookup('url', 'https://github.com/gremlin.keys', wantlist=True) }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: display ip ranges
  debug: msg="{{ lookup('url', 'https://ip-ranges.amazonaws.com/ip-ranges.json', split_lines=False) }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: url lookup using authentication
  debug: msg="{{ lookup('url', 'https://some.private.site.com/file.txt', username='bob', password='hunter2') }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: url lookup using headers
  debug: msg="{{ lookup('url', 'https://some.private.site.com/api/service', headers={'header1':'value1', 'header2':'value2'} ) }}"

Inputs

    
_terms:
    description: urls to query

headers:
    default: {}
    description: HTTP request headers
    type: dictionary
    version_added: '2.9'
    version_added_collection: ansible.builtin

password:
    description: Password to use for HTTP authentication.
    type: string
    version_added: '2.8'
    version_added_collection: ansible.builtin

username:
    description: Username to use for HTTP authentication.
    type: string
    version_added: '2.8'
    version_added_collection: ansible.builtin

use_proxy:
    default: true
    description: Flag to control if the lookup will observe HTTP proxy environment variables
      when present.
    type: boolean

split_lines:
    default: true
    description: Flag to control if content is returned as a list of lines or as a single
      text blob
    type: boolean

validate_certs:
    default: true
    description: Flag to control SSL certificate validation
    type: boolean

Outputs

_list:
  description: list of list of lines or content of url(s)