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.