ansible 2.8.0
Running uri module as
uri:
dest: .
url: https://{{ hostvars[inventory_hostname].ansible_host }}:{{ apache.port }}/context-root/some-context
validate_certs: false
return_content: true
follow_redirects: none
status_code:
- 302
register: page
changed_when: false
delegate_to: localhost
This results in a 302 with the Location header set to a “relative” url. Ansible follows the 302, ignoring the follow_redirects setting, and fails on the relative URL with the message
“msg”: “unknown url type: /cas/login?service=something”
The full traceback is:
WARNING: The below traceback may not be related to the actual failure.
File “/tmp/ansible_uri_payload__lMgyr/ansible_uri_payload.zip/ansible/module_utils/urls.py”, line 1353, in fetch_url
unix_socket=unix_socket)
File “/tmp/ansible_uri_payload__lMgyr/ansible_uri_payload.zip/ansible/module_utils/urls.py”, line 1251, in open_url
use_gssapi=use_gssapi, unix_socket=unix_socket)
File “/tmp/ansible_uri_payload__lMgyr/ansible_uri_payload.zip/ansible/module_utils/urls.py”, line 1157, in open
r = urllib_request.urlopen(*urlopen_args)
File “/usr/lib64/python2.7/urllib2.py”, line 154, in urlopen
return opener.open(url, data, timeout)
File “/usr/lib64/python2.7/urllib2.py”, line 423, in open
protocol = req.get_type()
File “/usr/lib64/python2.7/urllib2.py”, line 285, in get_type
raise ValueError, “unknown url type: %s” % self.__original
- Why is Ansible ignoring the follow_redirects setting
- Can Ansible follow relative URLs on 302?