ansible.builtin.url test – is the string a valid URL

Note

This test plugin is part of ansible-core and included in all Ansible installations. In most cases, you can use the short plugin name url. However, we recommend you use the Fully Qualified Collection Name (FQCN) ansible.builtin.url for easy linking to the plugin documentation and to avoid conflicting with other collections that may have the same test plugin name.

New in ansible-core 2.14

Synopsis

  • Validates a string to conform to the URL standard.

Input

This describes the input of the test, the value before is ansible.builtin.url or is not ansible.builtin.url.

Parameter

Comments

Input

string / required

Possible URL.

Keyword parameters

This describes keyword parameters of the test. These are the values key1=value1, key2=value2 and so on in the following examples: input is ansible.builtin.url(key1=value1, key2=value2, ...) and input is not ansible.builtin.url(key1=value1, key2=value2, ...)

Parameter

Comments

schemes

list / elements=string

Subset of URI schemas to validate against, otherwise any scheme is considered valid.

Examples

# simple URL
{{ 'http://example.com' is url }}
# looking only for file transfers URIs
{{ 'mailto://nowone@example.com' is not uri(schemes=['ftp', 'ftps', 'sftp', 'file']) }}
#  but it is according to standard
{{ 'mailto://nowone@example.com' is not uri }}
# more complex URL
{{ 'ftp://admin:secret@example.com/path/to/myfile.yml' is url }}

Return Value

Key

Description

Return value

boolean

Returns false if the string is not a URL, true otherwise.

Returned: success

Authors

  • Ansible Core

Hint

Configuration entries for each entry type have a low to high priority order. For example, a variable that is lower in the list will override a variable that is higher up.