uri module: fails to do POST due to unable to parse netscape cookie file

42 views
Skip to first unread message

vinod kumar

unread,
Aug 9, 2018, 2:26:05 AM8/9/18
to Ansible Project
I have below uri module where i am sending netscape cookie file.
It throws me back with error message,

    - name: Register
      uri:
        url: "https://{{ orch_ip }}:19443/2/platforms/xxx/providers"
        method: POST
        return_content: yes
        body: 'u{{ isilon_orch_service_account_key }}'
        body_format: json
        validate_certs: no
        status_code: 200,204
        headers:
          Cookie: 'u{{ isilon_orch_cookie_file }}'

I get below error message:

TASK [Register] *************************************************************************************************************************************
task path: /etc/ansible/playbooks/deploy_1.yml:48
fatal: [10.150.0.15]: FAILED! => {"changed": false, "connection": "close", "content": "<!DOCTYPE html>\n<html lang=\"en\">\n    <head>\n        <title>Bad Request</title>\n        <style>\n            html, body, pre {\n                margin: 0;\n                padding: 0;\n                font-family: Monaco, 'Lucida Console', monospace;\n                background: #ECECEC;\n            }\n            h1 {\n                margin: 0;\n                background: #AD632A;\n                padding: 20px 45px;\n                color: #fff;\n                text-shadow: 1px 1px 1px rgba(0,0,0,.3);\n                border-bottom: 1px solid #9F5805;\n                font-size: 28px;\n            }\n            p#detail {\n                margin: 0;\n                padding: 15px 45px;\n                background: #F6A960;\n                border-top: 4px solid #D29052;\n                color: #733512;\n                text-shadow: 1px 1px 1px rgba(255,255,255,.3);\n                font-size: 14px;\n                border-bottom: 1px solid #BA7F5B;\n            }\n        </style>\n    </head>\n    <body>\n        <h1>Bad Request</h1>\n\n        <p id=\"detail\">\n            For request 'POST /2/platforms/xxx/providers' [Bad request: Error decoding json body: com.fasterxml.jackson.core.JsonParseException: Unrecognized token &#x27;u&#x27;: was expecting (&#x27;true&#x27;, &#x27;false&#x27; or &#x27;null&#x27;)\n at [Source: (akka.util.ByteIterator$ByteArrayIterator$$anon$1); line: 1, column: 3]]\n        </p>\n\n    </body>\n</html>\n", "content_length": "1424", "content_type": "text/html; charset=utf-8", "date": "Thu, 09 Aug 2018 06:22:36 GMT", "msg": "Status code was not [200, 204]: HTTP Error 400: Bad Request", "redirected": false, "status": 400, "url": "https://10.150.0.4:19443/2/platforms/xxx/providers"}


below is {{ isilon_orch_cookie_file }} file looks like

#HttpOnly_10.150.0.4    FALSE   /       TRUE    0       PLAY_SESSION    eyJhbGciOiJIUzI1NiJ9.eyJkYXRhIjp7InRpbWUiOiIxNTMzNzk1NzU1MDY4IiwiVVVJRCI6IjI0MGIyInVzZXIiOiJhZG1pbiJ9zMzc5NTc1NX0.npAMiDyTLQIMZ1kV3A6oHlOjShdWo3nMzBRn7YjbI5A


Need help on what format of netscape cookie file should be allowed in uri to understand and authentiate

vinod kumar

unread,
Aug 9, 2018, 2:29:31 AM8/9/18
to Ansible Project
Running curl command as below works fine,

curl -X POST -k https://10.150.0.4:19443/2/platforms/xxx/providers -b ./cookie.txt --header "Content-Type:application/json" --data @key1.json
Reply all
Reply to author
Forward
0 new messages