On 04.07.2017 15:05, Rasmus Sjørslev wrote:
"json": {
            "code": 200,
            "data": {
                "DNSrecords": "1",
                "DNSrecursive": "1",
                "allowRequests": "1",
                "calculation": {
                    "Broadcast": "192.168.111.255",
                    "IP address": "/",
                    "Max host IP": "192.168.111.254",
                    "Min host IP": "192.168.111.1",
                    "Network": "192.168.111.0",
                    "Number of hosts": 254,
                    "Subnet Class": "private C",
                    "Subnet bitmask": "24",
                    "Subnet netmask": "255.255.255.0",
                    "Subnet wildcard": "0.0.0.255",
                    "Type": "IPv4"
...

what i am after here is the Subnet netmask in the data.calculation but when
i reference it like this:

"'{{ subnet_info.json.data.calculation.Subnet Netmask }}'"
or
'{{ subnet_info.json.data.calculation.Subnet Netmask }}'
or
"{{ subnet_info.json.data.calculation.Subnet Netmask }}"

i get the following error:

fatal: [localhost]: FAILED! => {
    "failed": true,
"msg": "template error while templating string: expected token 'end of
print statement', got 'Netmask'. String: '{{
subnet_info.json.data.calculation.Subnet Netmask }}'"
}

how can i get to that JSON data that contains a space and reference that as
a variable?

You can't use the dot notation when there are spaces, use square brackets instead.

"{{ subnet_info.json.data.calculation['Subnet netmask'] }}"

--
Kai Stian Olstad

--
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/41c80fe16a980212bc7acf761981f15c%40olstad.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to