hello,
I want to test if web redirect works first without making public. curl equivalent would be
uri module seems to be perfect for this but struggle with headers parameter for 'Host' header.
Task created
- name: Test redirect
uri:
url: http://localhost
method: GET
headers:
Host: "www.example.com"
status_code: 200,301,302
follow_redirects: all
timeout: 10
register: webpage
and this is error message I receive:
fatal: [ansible]: FAILED! => {"cache_control": "no-cache,no-store", "changed": false, "connection": "close", "content": "Error: Bad request. Hostname in the Host header is not sa", "content_length": "57", "content_type": "text/html", "msg": "Status code was not [200, 301, 302]: HTTP Error 400: Bad Rquest", "pragma": "no-cache", "redirected": false, "status": 400, "url": "http://127.0.0.1"}
Obviously something not right with header but also not sure about url. Any hint would be greatly appreciated. I could do work around by creating temporary record in /etc/hosts but really would like to try the more elegant way if possible.