Ansible Get_url module response HTTP Bad Request

431 views
Skip to first unread message

Shyam Yenna

unread,
Mar 1, 2017, 10:14:48 AM3/1/17
to Ansible Project
I am implementing below task and it throwing me HTTP Error: 400 Bad Request

FAILED! => {
    "changed": false,
    "dest": "/tmp",
    "failed": true,
    "gid": 0,
    "group": "root",
    "invocation": {
        "module_args": {
            "backup": false,
            "checksum": "md5:a33bdf347d40110c6d64d100fabc056d",
            "content": null,
            "delimiter": null,
            "dest": "/tmp",
            "directory_mode": null,
            "follow": false,
            "force": false,
            "force_basic_auth": false,
            "group": null,
            "headers": null,
            "http_agent": "ansible-httpget",
            "mode": null,
            "owner": null,
            "regexp": null,
            "remote_src": null,
            "selevel": null,
            "serole": null,
            "setype": null,
            "seuser": null,
            "sha256sum": "",
            "src": null,
            "timeout": 10,
            "tmp_dest": "",
            "unsafe_writes": null,
            "url": "https://backstage.forgerock.com/downloads/OpenDJ/OpenDJ Enterprise/3.0.0/OpenDJ 3 Zip/OpenDJ-3.0.0.zip",
            "url_password": "password",
            "url_username": "user",
            "use_proxy": true,
            "validate_certs": true
        },
        "module_name": "get_url"
    },
    "mode": "01777",
    "msg": "Request failed",
    "owner": "root",
    "response": "HTTP Error 400: Bad request",
    "size": 4096,
    "state": "directory",
    "status_code": 400,
    "uid": 0,
    "url": "http://backstage.forgerock.com/downloads/OpenDJ/OpenDJ Enterprise/3.0.0/OpenDJ 3 Zip/OpenDJ-3.0.0.zip"
}


I appreciate any help.

Thanks
Shyam

Dick Visser

unread,
Mar 2, 2017, 3:52:22 AM3/2/17
to ansible...@googlegroups.com
On 1 March 2017 at 16:14, Shyam Yenna <write...@gmail.com> wrote:

> I am implementing below task and it throwing me HTTP Error: 400 Bad Request

That's not a task, but the (failed) output of it.

Since you didn't post your actual task, I will guess that you're
downloading a ZIP file, but forgot to escape the spaces in the URL:

visser@cajones:~$ curl -I
"https://backstage.forgerock.com/downloads/OpenDJ/OpenDJ
Enterprise/3.0.0/OpenDJ 3 Zip/OpenDJ-3.0.0.zip"
HTTP/1.0 200 Connection established

HTTP/1.0 400 Bad request
Cache-Control: no-cache
Connection: close
Content-Type: text/html


Compare this to:

visser@cajones:~$ curl -I
"https://backstage.forgerock.com/downloads/OpenDJ/OpenDJ%20Enterprise/3.0.0/OpenDJ%203%20Zip/OpenDJ-3.0.0.zip"
HTTP/1.0 200 Connection established

HTTP/1.1 200 OK
Date: Thu, 02 Mar 2017 08:41:06 GMT
Server: Apache/2.4.6 (Red Hat) OpenSSL/1.0.0-fips OpenAM WPA/3.3.4
X-Frame-Options: SAMEORIGIN
Last-Modified: Fri, 17 Feb 2017 10:40:55 GMT
Accept-Ranges: bytes
Content-Length: 2128
Vary: Accept-Encoding
Cache-Control: max-age=0,no-cache
nid: prod2
Content-Type: text/html; charset=UTF-8
Set-Cookie: fr_backstage_lb_prod=prod2; path=/


However, this isn't a file but instead a web page asking to sign in.
With valid credentials that might work, but it could also be that the
server want something more fancy than basic auth.
It's up to you to find that out.
If that happens, you'd probably have to store a cookie first.

Note that your URL initially gets redirected to HTTPS - you might want
to use that to start with.


Dick








--
Dick Visser
Sr. System & Network Engineer
GÉANT

Want to join us? We're hiring: https://www.geant.org/jobs
Reply all
Reply to author
Forward
0 new messages