This is what I get from the API :
HTTP/1.1 201 Created
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
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] *************************************************
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’]
REMOTE_MODULE uri url=https://api.ccu.akamai.com/ccu/v2/queues/default method=POST user=xxxxxx password=xxxxx HEADER_Content-Type=“application/json” body=‘{“objects”:[“http://xxxx/images/flags/uk.png”]}’ status_code=201 return_content=yes
PUT /tmp/tmpR6pSOQ TO /usr/home/jamengual/.ansible/tmp/ansible-1385033255.71-37626758703564/uri
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.