Ansible - Resolve "unknown url type"
by
Jeremy Canfield |
Updated: February 07 2024
| Ansible articles
Let's say something like this is being returned.
fatal: [localhost]: FAILED! => {
"attempts": 3,
"changed": false,
"msg": "unknown url type: api.example.com/api/v1/foo.txt",
"status": -1,
"url": "api.example.com/api/v1/foo.txt"
}
I happened up this when using the uri module, like this. Notice in this example that the URL does not begin with a protocol, such as http or https or ftp.
---
- hosts: localhost
tasks:
- uri:
url: api.example.com/api/v1/foo.txt
force_basic_auth: yes
url_username: john.doe
url_password: itsasecret
validate_certs: no
timeout: 60
force: yes
register: out
run_once: true
retries: 3
delay: 30
until: out.status == 200
- debug:
var: out
...
I simply just had to update the uri module to include the protocol, https in this example.
---
- hosts: localhost
tasks:
- uri:
url: https://api.example.com/api/v1/foo.txt
force_basic_auth: yes
url_username: john.doe
url_password: itsasecret
validate_certs: no
timeout: 60
force: yes
register: out
run_once: true
retries: 3
delay: 30
until: out.status == 200
- debug:
var: out
...
Did you find this article helpful?
If so, consider buying me a coffee over at