Bootstrap FreeKB - Ansible - Resolve "unknown url type"
Ansible - Resolve "unknown url type"

Updated:   |  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 Buy Me A Coffee



Comments


Add a Comment


Please enter f0a796 in the box below so that we can be sure you are a human.