I am trying to get back into some Ansible automation after some absence but 
get stuck immediately trying to get the IP address of an Azure VM from 
ansible facts:

ok: [localhost] => {
    "*interface_facts.ansible_facts.azure_networkinterfaces*": [
        {
            "etag": "W/\"a4csdf-b1120d-5c9fb31354129\"",
            "id": 
"/subscriptions/a444df-b1120d-5c9fb31-354129-2gbf3e5b/resourceGroups/testRG/providers/Microsoft.Network/networkInterfaces/testvm1-eth0",
            "location": "westeurope",
            "*properties*": {
                "dnsSettings": {
                    "appliedDnsServers": [],
                    "dnsServers": [],
                    "internalDomainNameSuffix": 
"kttxupoc3ofsdf25452peia.ax.internal.cloudapp.net"
                },
                "enableIPForwarding": false,
                "*ipConfigurations*": [
                    {
                        "etag": 
"W/\"ae60d652-3b57-4cfd-b10d-5c9fb11296e6\"",
                        "id": 
"/subscriptions/a444df-b1120d-5c9fb31-354129-2gbf3e5b/resourceGroups/testRG/providers/Microsoft.Network/networkInterfaces/testvm1-eth0/ipConfigurations/default",
                        "name": "default",
                        "*properties*": {
                            "privateIPAddress": "192.168.1.2",
                            *"privateIPAddressVersion": "IPv4",*
                            "privateIPAllocationMethod": "Dynamic",
                            "provisioningState": "Succeeded",
                            "subnet": {
                                "id": 
"/subscriptions/a444df-b1120d-5c9fb31-354129-2gbf3e5b/resourceGroups/testRG/providers/Microsoft.Network/virtualNetworks/IaaS-Vnet/subnets/IaaS-Test-FE-Subnet"
                            }
                        }
                    }
                ],
                "macAddress": "0E-0D-3E-29-FE-AF",
                "networkSecurityGroup": {
                    "id": 
"/subscriptions/a4csdf-b1120d-5c9fb31354129/resourceGroups/testRG/providers/Microsoft.Network/networkSecurityGroups/testvm1-eth001"
                },
                "primary": true,
                "provisioningState": "Succeeded",
                "resourceGuid": "a7182a83-61bc-3bed-9758-2d72f251952d",
                "virtualMachine": {
                    "id": 
"/subscriptions/1a4csdf-b1120d-5c9fb31329-e5b/resourceGroups/testRG/providers/Microsoft.Compute/virtualMachines/testvm1"
                }
            }
        }
    ]
}


I Thought that I could get the IP by using 
"interface_facts.ansible_facts.azure_networkinterfaces.properties,ipConfigurations.properties.privateIPAddress

But no amounts of dots and square brackets gets me past the 
interface_facts.ansible_facts.azure_networkinterfaces level, anything below 
just responds "VARIABLE IS NOT DEFINED!"

I am pretty sure this is just a YAML list/dict noob issue, but after hours 
of searching I am still lost.

Can anyone please point me in the right direction?





-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/a71513d7-57a7-425b-8733-2bc96aecb978%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to