On 04. juli 2017 18:59, Jan Mattsson wrote:
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*": [
Here you have a list.
{
"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*": [
Here you have a list.
{
"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
You have two list in you structure to reach privateIPAddress, try
interface_facts.ansible_facts.azure_networkinterfaces.0.properties.ipConfigurations.0.properties.privateIPAddress
it can also be written like this
interface_facts.ansible_facts.azure_networkinterfaces[0].properties.ipConfigurations[0].properties.privateIPAddress
--
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 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/f737accc-93c3-9d7c-a321-c9ad3261f9fe%40olstad.com.
For more options, visit https://groups.google.com/d/optout.