Im using the uri module to call a REST endpoint but the JSON structure 
returns contains a space which im not sure how to escape.

First the call i make and register:

    - name: Get subnet information (DNS, gateway, netmask etc.)
      uri:
        url: "{{ phpipam_url }}/subnets/7/"
        method: GET
        headers:
          token: "{{ ipam_login.json.data.token }}"
        status_code: 200
      register: subnet_info


subnet_info then contains the JSON payload:

"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 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/dbbb5f99-35f5-4f91-8248-ccdb9dc45dfe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to