Here is the info:

I'm trying to send a json object to akamai with the uri module but it fails 
saying that is not a valid json object but the debug message shows in the 
right format.

here is the requeriments from akamai 
: https://api.ccu.akamai.com/ccu/v2/docs/index.html#section_OtherInterfaces

Any ideas whi uri module changes from double quotes to single quotes ?

Thanks.

[playbook:

---
- hosts: localhost
  connection: local
  gather_facts: False
  tasks:
   - set_fact:
      urls: '{"objects":[{{urllist}}]}'
   - debug: var=urls
   - name: Flushing Akamai cache
     action: uri url=https://api.ccu.akamai.com/ccu/v2/queues/default
             method=POST user=aaaa password=aaa
             HEADER_Content-Type="application/json" 
             body='{{urls}}'
             status_code=201
             return_content=yes
     register: akamairesponse

cat args.yml 
urllist: 
'"http://url/file/pepe.png","http://url/file/pepe.png","http://url/file/pepe.png","http://url/file/pepe.png";'


[jamengual@pepe ~]$ ansible-playbook -vvv -i /etc/ansible/hosts 
/home/jamengual/akamai.yml -e @args.yml

PLAY [localhost] 
************************************************************** 

TASK: [set_fact ] 
************************************************************* 
ok: [localhost] => {"ansible_facts": {"urls": {"objects": 
["http://url/file/pepe.png";, "http://url/file/pepe.png";, 
"http://url/file/pepe.png";, "http://url/file/pepe.png"]}}}

TASK: [debug var=urls] 
******************************************************** 
ok: [localhost] => {
    "urls": {
        "objects": [
            "http://url/file/pepe.png";, 
            "http://url/file/pepe.png";, 
            "http://url/file/pepe.png";, 
            "http://url/file/pepe.png";
        ]
    }
}

TASK: [Flushing Akamai cache] 
************************************************* 
<localhost> EXEC ['/bin/sh', '-c', 'mkdir -p 
$HOME/.ansible/tmp/ansible-1385480305.84-120825882016653 && chmod a+rx 
$HOME/.ansible/tmp/ansible-1385480305.84-120825882016653 && echo 
$HOME/.ansible/tmp/ansible-1385480305.84-120825882016653']
<localhost> REMOTE_MODULE uri 
url=https://api.ccu.akamai.com/ccu/v2/queues/default method=POST user=aaa 
password=aaa HEADER_Content-Type="application/json" body='{'objects': 
['http://url/file/pepe.png', 'http://url/file/pepe.png', 
'http://url/file/pepe.png', 'http://url/file/pepe.png']}' status_code=201 
return_content=yes
<localhost> PUT /tmp/tmpHoHxi9 TO 
/usr/home/jamengual/.ansible/tmp/ansible-1385480305.84-120825882016653/uri
<localhost> EXEC ['/bin/sh', '-c', '/usr/local/bin/python 
/usr/home/jamengual/.ansible/tmp/ansible-1385480305.84-120825882016653/uri; 
rm -rf 
/usr/home/jamengual/.ansible/tmp/ansible-1385480305.84-120825882016653/ 
>/dev/null 2>&1']
failed: [localhost] => {"allow": "GET, HEAD, POST", "connection": "close", 
"content": "{\"title\": \"bad request\", \"httpStatus\": 400, \"detail\": 
\"Invalid JSON document\", \"describedBy\": 
\"https://api.ccu.akamai.com/ccu/v2/errors/bad-request\"}";, 
"content_length": "149", "content_type": "application/api-problem+json", 
"date": "Tue, 26 Nov 2013 22:43:14 GMT", "failed": true, "redirected": 
false, "server": "Apache", "status": 400, "vary": "Authorization"}
msg: Status code was not 201

FATAL: all hosts have already failed -- aborting

PLAY RECAP 
******************************************************************** 
           to retry, use: --limit @/usr/home/jamengual/akamai.retry

localhost                  : ok=2    changed=0    unreachable=0    failed=1 
  

-- 
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.

Reply via email to