Use array syntax:

- debug: msg="{{ logon.json['Dcnm-Token'] }}"



On Monday, June 23, 2014 1:52:06 PM UTC+2, [email protected] wrote:
>
> Hi,
>
> I'm using the URI module with a REST/json API. First I'm logging on, to 
> get a token, wich I want to use in further requests. Its seems that the 
> returnded token contains a "-" (minus sign) in its key name. I know that 
> "-" ist not a valide ansible variable. And this seems to be a problem:
>
> - name: REST logon
>   uri: url="http://XXXXXXX/rest/logon"; method="POST" 
> HEADER_Content-Type="application/json" user="XXXXXX" password="XXXXXX" 
>   register: logon
>
> - debug: msg="{{ logon.json.Dcnm-Token }}"
>
> $ ansible-playbook -v play.yml
> PLAY [test] 
> ******************************************************************* 
>
> TASK: [REST logon] 
> ************************************************************ 
> ok: [XXXXXXX] => {"changed": false, "content_length": "61", 
> "content_type": "application/json", "date": "Mon, 23 Jun 2014 11:46:54 
> GMT", "json": {"Dcnm-Token": 
> "/isIApYCIM12Ms50gfjlX/ppLkNeuCp1wZHKQKHB2N8="}, "redirected": false, 
> "server": "Apache", "status": 200}
>
> TASK: [debug msg="{{logon.json.Dcnm-Token}}"] 
> ********************************* 
> fatal: [XXXXXX] => unable to look up a name or access an attribute in 
> template string
>
> In other places (i.e. facts) "-" is convertet to "_". This seems not to be 
> the case here (ansible 1.4.4). Are there any options?
>
> Thanks, Sascha.
>

-- 
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].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/d5e2b684-1355-4e34-95d0-a02bf3334810%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to