I'm assuming that's the output from just {{akamairesponse}} ? If so what
do you get when you take it to the next level of {{akamairesponse.content}}?
Not sure if it's a copy/paste issue but it looks like the response is
missing a trailing '}' as well, which could be an issue.
Romeo
On Thu, Nov 21, 2013 at 2:19 PM, PePe Amengual <[email protected]>wrote:
> this :
>
> {u'status': u'201', u'content_length': u'268', u'content_type':
> u'application/json', u'changed': False, u'vary': u'Authorization',
> u'server': u'Apache', u'content': u'{estimatedSeconds: 420, progressUri:
> /ccu/v2/purges/41224eec-52df-11e3-8be1-212a0be1212a, purgeId:
> 41224eec-52df-11e3-8be1-212a0be1212a, supportId:
> 17PY1385060455982392-223450208, httpStatus: 201, detail: Request"}
>
>
>
> On Thursday, 21 November 2013 19:33:23 UTC, Romeo Theriault wrote:
>
>> What is the debug output of just {{akamairesponse}} and
>> {{akamairesponse.content}} ? Just trying to narrow down...
>>
>>
>> On Thu, Nov 21, 2013 at 8:31 AM, PePe Amengual <[email protected]>wrote:
>>
>>> This is what I get from the API :
>>>
>>>
>>> HTTP/1.1 201 Created
>>> Date: Thu, 21 Nov 2013 18:01:08 GMT
>>> Server: Apache
>>> Content-Length: 268
>>> Content-Location: /ccu/v2/purges/e771b867-52d6-11e3-bcaf-2a98bcaf2a98
>>> Allow: GET, HEAD, POST
>>> Vary: Authorization
>>> Content-Type: application/json
>>>
>>> {"estimatedSeconds": 420, "progressUri":
>>> "/ccu/v2/purges/e771b867-52d6-11e3-bcaf-2a98bcaf2a98",
>>> "purgeId": "e771b867-52d6-11e3-bcaf-2a98bcaf2a98", "supportId":
>>> "17PY1385056868737216-189879392", "httpStatus": 201, "detail": "Request
>>> accepted.", "pingAfterSeconds": 420}⏎
>>>
>>> my uri request from the playbook :
>>>
>>> tasks:
>>> - name: Flushing Akamai cache
>>> action: uri
>>> url=https://api.ccu.akamai.com/ccu/v2/queues/default<https://www.google.com/url?q=https%3A%2F%2Fapi.ccu.akamai.com%2Fccu%2Fv2%2Fqueues%2Fdefault&sa=D&sntz=1&usg=AFQjCNEGk6C_llfcf2mNc2Yj-k7-LQgOng>
>>> method=POST user=aaaa password=aaaa
>>> HEADER_Content-Type="application/json"
>>> body='{"objects":["{{urllist}}"]}'
>>> status_code=201
>>> return_content=yes
>>> register: akamairesponse
>>> - debug: msg="value of {{akamairesponse.content.purgeId}}"
>>> - name: Notifing
>>> action: hipchat token=aaa room=Akamai msg="Purged {{urllist}}"
>>> action: hipchat token=aaa room=Akamai msg="{{akamairesponse.content.
>>> purgerId}}"
>>>
>>> I get in hipchat this {{akamairesponse.content.purgerId}} like a string
>>> is not actually parsing the data.
>>>
>>> the debug :
>>>
>>> PLAY [localhost] ******************************
>>> ********************************
>>>
>>> TASK: [Flushing Akamai cache] ******************************
>>> *******************
>>> <localhost> EXEC ['/bin/sh', '-c', 'mkdir -p
>>> $HOME/.ansible/tmp/ansible-1385033255.71-37626758703564
>>> && chmod a+rx $HOME/.ansible/tmp/ansible-1385033255.71-37626758703564
>>> && echo $HOME/.ansible/tmp/ansible-1385033255.71-37626758703564']
>>> <localhost> REMOTE_MODULE uri url=https://api.ccu.akamai.
>>> com/ccu/v2/queues/default<https://www.google.com/url?q=https%3A%2F%2Fapi.ccu.akamai.com%2Fccu%2Fv2%2Fqueues%2Fdefault&sa=D&sntz=1&usg=AFQjCNEGk6C_llfcf2mNc2Yj-k7-LQgOng>method=POST
>>> user=xxxxxx password=xxxxx HEADER_Content-Type="application/json"
>>> body='{"objects":["http://xxxx/images/flags/uk.png<http://www.google.com/url?q=http%3A%2F%2Fxxxx%2Fimages%2Fflags%2Fuk.png&sa=D&sntz=1&usg=AFQjCNEn0EpG87S0Qw6v96yfnSH22ql5fg>"]}'
>>> status_code=201 return_content=yes
>>> <localhost> PUT /tmp/tmpR6pSOQ TO /usr/home/jamengual/.ansible/
>>> tmp/ansible-1385033255.71-37626758703564/uri
>>> <localhost> EXEC ['/bin/sh', '-c', '/usr/local/bin/python
>>> /usr/home/jamengual/.ansible/tmp/ansible-1385033255.71-37626758703564/uri;
>>> rm -rf
>>> /usr/home/jamengual/.ansible/tmp/ansible-1385033255.71-37626758703564/
>>> >/dev/null 2>&1']
>>> ok: [localhost] => {"allow": "GET, HEAD, POST", "changed": false,
>>> "content": "{\"estimatedSeconds\": 420, \"progressUri\":
>>> \"/ccu/v2/purges/bcb3d980-52da-11e3-b16b-21bd716b21bd\", \"purgeId\":
>>> \"bcb3d980-52da-11e3-b16b-21bd716b21bd\", \"supportId\":
>>> \"17PY1385058515823533-206664800\", \"httpStatus\": 201, \"detail\":
>>> \"Request accepted.\", \"pingAfterSeconds\": 420}", "content_length":
>>> "268", "content_location":
>>> "/ccu/v2/purges/bcb3d980-52da-11e3-b16b-21bd716b21bd",
>>> "content_type": "application/json", "date": "Thu, 21 Nov 2013 18:28:35
>>> GMT", "json": {"detail": "Request accepted.", "estimatedSeconds": 420,
>>> "httpStatus": 201, "pingAfterSeconds": 420, "progressUri":
>>> "/ccu/v2/purges/bcb3d980-52da-11e3-b16b-21bd716b21bd", "purgeId":
>>> "bcb3d980-52da-11e3-b16b-21bd716b21bd", "supportId":
>>> "17PY1385058515823533-206664800"}, "redirected": false, "server":
>>> "Apache", "status": "201", "vary": "Authorization"}
>>>
>>> TASK: [debug msg="value of {{akamairesponse.content.purgeId}}"]
>>> ***************
>>> fatal: [localhost] => One or more undefined variables: 'unicode object'
>>> has no attribute 'purgeId'
>>>
>>> FATAL: all hosts have already failed -- aborting
>>>
>>> PLAY RECAP ************************************************************
>>> ********
>>> to retry, use: --limit @/usr/home/jamengual/akamai.retry
>>>
>>> localhost : ok=1 changed=0 unreachable=1
>>> failed=0
>>>
>>> I tried with : {{akamairesponse.content.purgeId}} and
>>> {{akamairesponse.content.[purgeId]}}, {{akamairesponse.content.["purgeId"]}}
>>> and {{akamairesponse.content."purgeId"}} and it doesn't work.
>>>
>>> am I doing something wrong ?
>>>
>>> Thanks.
>>>
>>> On Thursday, 21 November 2013 02:44:35 UTC, Romeo Theriault wrote:
>>>
>>>> On Wed, Nov 20, 2013 at 2:24 PM, PePe Amengual <[email protected]>wrote:
>>>>
>>>>> I'm basically having the same issue I need to get from this :
>>>>>
>>>>> {
>>>>> "httpStatus" : 201,
>>>>> "detail" : "Request accepted.",
>>>>> "estimatedSeconds" : 420,
>>>>> "purgeId" : "95b5a092-043f-4af0-843f-aaf0043faaf0",
>>>>> "progressUri" : "/ccu/v2/purges/95b5a092-043f-
>>>>> 4af0-843f-aaf0043faaf0",
>>>>> "pingAfterSeconds" : 420,
>>>>> "supportId" : "17PY1321286429616716-211907680",
>>>>> }
>>>>>
>>>>> the pingAfterSeconds to use it in a wait_for task and the purgeid but
>>>>> this is a JSON so dunno if the process is similar to a string parsing?
>>>>>
>>>>
>>>>
>>>> If the web service returns a Content-type header set as
>>>> "application/json" and the response you get is valid json then the uri
>>>> module will parse the JSON and make it available via the key.
>>>>
>>>> See
>>>> https://github.com/ansible/ansible/pull/2119<https://www.google.com/url?q=https%3A%2F%2Fgithub.com%2Fansible%2Fansible%2Fpull%2F2119&sa=D&sntz=1&usg=AFQjCNFk00orJ65Ulvf9uk8Gr6Ch21D75w>for
>>>> more details.
>>>>
>>>> So you should be able to do something like {{ register_var.content.
>>>> pingAfterSeconds }} to get the value. (Not tested, but you get the
>>>> idea.)
>>>>
>>>> Once you get it, it would be good to send a pull request better
>>>> documenting this :)
>>>>
>>>>
>>>> --
>>>> Romeo
>>>>
>>> --
>>> 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 [email protected].
>>>
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>
>>
>>
>> --
>> Romeo
>>
> --
> 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 [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
--
Romeo
--
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.