So I tried with to_json:
plase look closely to the TASK: [set_fact ] that shows the right format and then look at the TASK: [Flushing Akamai cache] where it shows in single cuotes that is where the problem is!.
When using - debug: var={{ urls | to_jason }} shows some empty string there and yes I have jinga2 installed ( using 1.4 in freebsd)
Thanks.
this is the debug :
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 | to_jason}}] *****************************************
ok: [localhost] => {
“{{urls”: “{{ {{urls }}”
}
TASK: [Flushing Akamai cache] *************************************************
EXEC [‘/bin/sh’, ‘-c’, ‘mkdir -p $HOME/.ansible/tmp/ansible-1385551881.43-185813033534451 && chmod a+rx $HOME/.ansible/tmp/ansible-1385551881.43-185813033534451 && echo $HOME/.ansible/tmp/ansible-1385551881.43-185813033534451’]
REMOTE_MODULE uri url=https://api.ccu.akamai.com/ccu/v2/queues/default method=POST user=aaaaaa password=aaaaa 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
PUT /tmp/tmp_lboPi TO /usr/home/jamengual/.ansible/tmp/ansible-1385551881.43-185813033534451/uri
EXEC [’/bin/sh’, ‘-c’, ‘/usr/local/bin/python /usr/home/jamengual/.ansible/tmp/ansible-1385551881.43-185813033534451/uri; rm -rf /usr/home/jamengual/.ansible/tmp/ansible-1385551881.43-185813033534451/ >/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”: “Wed, 27 Nov 2013 18:38:35 GMT”, “failed”: true, “redirected”: false, “server”: “Apache”, “status”: 400, “vary”: “Authorization”}
msg: Status code was not 201
FATAL: all hosts have already failed – aborting
running ansible like this :
ansible-playbook -vvv -i /etc/ansible/hosts /home/jamengual/akamai.yml -e @args.yml
args.yml :
urllist: ‘“http://url/file/pepe.png",“http://url/file/pepe.png”,“http://url/file/pepe.png”,"http://url/file/pepe.png”’
Playbook :