Reputation: 847
"custom_fields": {
"Datacentre Code": "p",
"Region": "EU"
},
I have the data format above, and I want to access the "Datacentre code" and return the result.
To access the Region I run the below command
{% set Region = item.resultDC.custom_fields.Region %}
To access the DC code I am running the below command
{% set DCCode= item.resultDC.custom_fields.Datacentre Code %}
This gives me the following error, how do I get this variable
AnsibleError: template error while templating string: expected token 'end of statement block', got 'Code
Upvotes: 1
Views: 3112
Reputation: 443
I believe that you can use the syntax item.resultDC.custom_fields['Datacentre Code']
to access properties of a dict like that.
Upvotes: 2