knowledge/technology/tools/Ansible/lookups/ansible.builtin.url.md
2023-12-04 11:02:23 +01:00

2 KiB

ansible.builtin.url

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

Parameters

Parameter Type Description
headers dictionary HTTP request headers
password string Password to use for HTTP authentication.
split_lines boolean (Default: true) Flag to control if content is returned as a list of lines or as a single text blob
username string Username to use for HTTP authentication.
validate_certs boolean (Default: true) Flag to control SSL certificate validation

Examples

- name: url lookup splits lines by default
  ansible.builtin.debug: msg="{{item}}"
  loop: "{{ lookup('ansible.builtin.url', 'https://github.com/gremlin.keys', wantlist=True) }}"

- name: display ip ranges
  ansible.builtin.debug: msg="{{ lookup('ansible.builtin.url', 'https://ip-ranges.amazonaws.com/ip-ranges.json', split_lines=False) }}"

- name: url lookup using authentication
  ansible.builtin.debug: msg="{{ lookup('ansible.builtin.url', 'https://some.private.site.com/file.txt', username='bob', password='hunter2') }}"

- name: url lookup using basic authentication
  ansible.builtin.debug:
    msg: "{{ lookup('ansible.builtin.url', 'https://some.private.site.com/file.txt', username='bob', password='hunter2', force_basic_auth='True') }}"

- name: url lookup using headers
  ansible.builtin.debug:
    msg: "{{ lookup('ansible.builtin.url', 'https://some.private.site.com/api/service', headers={'header1':'value1', 'header2':'value2'} ) }}"