hello,

I want to test if web redirect works first without making public. curl 
equivalent would be
curl -LI --header 'Host: www.example.com' 'http://localhost'

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.

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/4e56d0c8-241e-490f-b074-91368113b07b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to