我无法解析后面的输出。尝试获取IP地址。
我正在尝试获取azure vm的IP地址,以获取IP。我正在使用azure_rm_networkinterface_facts模块,在该模块中,我将提供nic名称,该名称存储在节食中。
这是我要解析的输出。
ok: [
localhost
]=>(item={
'value': [
u'datamover-nic10'
],
'key': u'data-mover'
})=>{
"ansible_facts": {
"azure_networkinterfaces": [
{
"etag": "W/\"08842209-be15-1144f26\"",
"id": "/subscriptions/1cf78a5c-5a30--c52c2d3d21b6/resourceGroups/DEVT/providers/Microsoft.Network/networkInterfaces/datamover-nic10",
"location": "westus",
"name": "datamover-nic10",
"properties": {
"dnsSettings": {
"appliedDnsServers": [
],
"dnsServers": [
],
"internalDomainNameSuffix": "3endvnfzb.dx.internal.cloudapp.net"
},
"enableAcceleratedNetworking": false,
"enableIPForwarding": false,
"ipConfigurations": [
{
"etag": "W/\"088421144f26\"",
"id": "/subscriptions/1cf78a52c2d3d21b6/resourceGroups/DEVT/providers/Microsoft.Network/networkInterfaces/datamover-nic10/ipConfigurations/ip1",
"name": "ip1",
"properties": {
"primary": true,
"privateIPAddress": "10.172.240.11",
"privateIPAddressVersion": "IPv4",
"privateIPAllocationMethod": "Static",
"provisioningState": "Succeeded",
"subnet": {
"id": "/subscriptions/1cf78a5c-5ac2d3d21b6/resourceGroups/DEVT/providers/Microsoft.Network/virtualNetworks/vNetOne/subnets/vmsubnet"
}
}
}
],
"macAddress": "00-0D-3A-36-B3-5C",
"networkSecurityGroup": {
"id": "/subscriptions/1cf78ad3d21b6/resourceGroups/DEVT/providers/Microsoft.Network/networkSecurityGroups/datamover-nsg"
},
"primary": true,
"provisioningState": "Succeeded",
"resourceGuid": "03114",
"virtualMachine": {
"id": "/subscriptions/1cf7d3d21b6/resourceGroups/DEVT/providers/Microsoft.Compute/virtualMachines/datamover"
}
},
"tags": {
"component": "datamover",
"provider": "B50E5F"
},
"type": "Microsoft.Network/networkInterfaces"
}
]
},
"changed": false,
"item": {
"key": "data-mover",
"value": [
"datamover-nic10"
]
}
}ok: [
localhost
]=>(item={
'value': [
u'database-nic00'
],
'key': u'database'
})=>{
"ansible_facts": {
"azure_networkinterfaces": [
{
"etag": "W/\"60bfd8c17323612\"",
"id": "/subscriptions/1cf72d3d21b6/resourceGroups/DEVT/providers/Microsoft.Network/networkInterfaces/database-nic00",
"location": "westus",
"name": "database-nic00",
"properties": {
"dnsSettings": {
"appliedDnsServers": [
],
"dnsServers": [
],
"internalDomainNameSuffix": "3wjfzb.dx.internal.cloudapp.net"
},
"enableAcceleratedNetworking": false,
"enableIPForwarding": false,
"ipConfigurations": [
{
"etag": "W/\"603612\"",
"id": "/subscriptions/1c2d3d21b6/resourceGroups/DEVT/providers/Microsoft.Network/networkInterfaces/database-nic00/ipConfigurations/ip1",
"name": "ip1",
"properties": {
"primary": true,
"privateIPAddress": "10.172.240.4",
"privateIPAddressVersion": "IPv4",
"privateIPAllocationMethod": "Static",
"provisioningState": "Succeeded",
"subnet": {
"id": "/subscriptions/1c3d21b6/resourceGroups/DEVT/providers/Microsoft.Network/virtualNetworks/vNetOne/subnets/vmsubnet"
}
}
},
{
"etag": "W/\"60b3612\"",
"id": "/subscriptions/1cfd3d21b6/resourceGroups/DEVT/providers/Microsoft.Network/networkInterfaces/database-nic00/ipConfigurations/ip2",
"name": "ip2",
"properties": {
"primary": false,
"privateIPAddress": "10.172.0.6",
"privateIPAddressVersion": "IPv4",
"privateIPAllocationMethod": "Static",
"provisioningState": "Succeeded",
"subnet": {
"id": "/subscriptions/1d3d21b6/resourceGroups/DEVT/providers/Microsoft.Network/virtualNetworks/vNetOne/subnets/vmsubnet"
}
}
}
],
"macAddress": "00-0D-3A-36-BC-FB",
"networkSecurityGroup": {
"id": "/subscriptions/1cf52c2d3d21b6/resourceGroups/ImcSite-UPAASDEVT/providers/Microsoft.Network/networkSecurityGroups/database-nsg"
},
"primary": true,
"provisioningState": "Succeeded",
"resourceGuid": "4d2fd4441e3c",
"virtualMachine": {
"id": "/subscriptions/1cf7d3d21b6/resourceGroups/DEVT/providers/Microsoft.Compute/virtualMachines/database-vm0"
}
},
"tags": {
"component": "database",
"provider": "B52B9A0E5F"
},
"type": "Microsoft.Network/networkInterfaces"
}
]
},
"changed": false,
"item": {
"key": "database",
"value": [
"database-nic00"
]
}
}
我试图使用以下方法从输出中解析并获取10.172.240.11和10.172.240.4地址。你能请人帮我吗?
- debug: msg=" {{ item.value[0] }}"
with_dict:
- "{{ vm_net_intf }}"
我希望在调试中打印10.172.240.11和10.172.240.4 ip地址
答案 0 :(得分:0)
ansible_facts 的最后一部分如下所示
change
给予(节略):
undefined