ansible / ansible.builtin / v2.16.5 / lookup / url return contents from URL | "added in version" 1.9 of ansible.builtin" Authors: Brian Coca (@bcoca)ansible.builtin.url (v2.16.5) — lookup
pip
Install with pip install ansible-core==2.16.5
Returns the content of the URL requested to be used as data in play.
- 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'} ) }}"
force: default: false description: Whether or not to set "cache-control" header with value "no-cache" env: - name: ANSIBLE_LOOKUP_URL_FORCE ini: - key: force section: url_lookup type: boolean vars: - name: ansible_lookup_url_force version_added: '2.10' version_added_collection: ansible.builtin _terms: description: urls to query ca_path: description: String of file system path to CA cert bundle to use env: - name: ANSIBLE_LOOKUP_URL_CA_PATH ini: - key: ca_path section: url_lookup type: string vars: - name: ansible_lookup_url_ca_path version_added: '2.10' version_added_collection: ansible.builtin ciphers: description: - SSL/TLS Ciphers to use for the request - When a list is provided, all ciphers are joined in order with C(:) - See the L(OpenSSL Cipher List Format,https://www.openssl.org/docs/manmaster/man1/openssl-ciphers.html#CIPHER-LIST-FORMAT) for more details. - The available ciphers is dependent on the Python and OpenSSL/LibreSSL versions elements: string env: - name: ANSIBLE_LOOKUP_URL_CIPHERS ini: - key: ciphers section: url_lookup type: list vars: - name: ansible_lookup_url_ciphers version_added: '2.14' version_added_collection: ansible.builtin headers: default: {} description: HTTP request headers type: dictionary version_added: '2.9' version_added_collection: ansible.builtin timeout: default: 10 description: How long to wait for the server to send data before giving up env: - name: ANSIBLE_LOOKUP_URL_TIMEOUT ini: - key: timeout section: url_lookup type: float vars: - name: ansible_lookup_url_timeout version_added: '2.10' 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_netrc: default: true description: - Determining whether to use credentials from ``~/.netrc`` file - By default .netrc is used with Basic authentication headers - When set to False, .netrc credentials are ignored env: - name: ANSIBLE_LOOKUP_URL_USE_NETRC ini: - key: use_netrc section: url_lookup type: boolean vars: - name: ansible_lookup_url_use_netrc version_added: '2.14' 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 http_agent: default: ansible-httpget description: User-Agent to use in the request. The default was changed in 2.11 to V(ansible-httpget). env: - name: ANSIBLE_LOOKUP_URL_AGENT ini: - key: agent section: url_lookup type: string vars: - name: ansible_lookup_url_agent version_added: '2.10' version_added_collection: ansible.builtin use_gssapi: default: false description: - Use GSSAPI handler of requests - As of Ansible 2.11, GSSAPI credentials can be specified with O(username) and O(password). env: - name: ANSIBLE_LOOKUP_URL_USE_GSSAPI ini: - key: use_gssapi section: url_lookup type: boolean vars: - name: ansible_lookup_url_use_gssapi version_added: '2.10' version_added_collection: ansible.builtin 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 unix_socket: description: String of file system path to unix socket file to use when establishing connection to the provided url env: - name: ANSIBLE_LOOKUP_URL_UNIX_SOCKET ini: - key: unix_socket section: url_lookup type: string vars: - name: ansible_lookup_url_unix_socket version_added: '2.10' version_added_collection: ansible.builtin validate_certs: default: true description: Flag to control SSL certificate validation type: boolean follow_redirects: default: urllib2 description: String of urllib2, all/yes, safe, none to determine how redirects are followed, see RedirectHandlerFactory for more information env: - name: ANSIBLE_LOOKUP_URL_FOLLOW_REDIRECTS ini: - key: follow_redirects section: url_lookup type: string vars: - name: ansible_lookup_url_follow_redirects version_added: '2.10' version_added_collection: ansible.builtin force_basic_auth: default: false description: Force basic authentication env: - name: ANSIBLE_LOOKUP_URL_FORCE_BASIC_AUTH ini: - key: force_basic_auth section: url_lookup type: boolean vars: - name: ansible_lookup_url_force_basic_auth version_added: '2.10' version_added_collection: ansible.builtin unredirected_headers: description: A list of headers to not attach on a redirected request elements: string env: - name: ANSIBLE_LOOKUP_URL_UNREDIR_HEADERS ini: - key: unredirected_headers section: url_lookup type: list vars: - name: ansible_lookup_url_unredir_headers version_added: '2.10' version_added_collection: ansible.builtin
_list: description: list of list of lines or content of url(s) elements: str type: list