Not able to get Azure VM private IP using Ansible

2019-04-04T01:43:07

I am trying to write the Private IP address of virtual machine created by Ansible into host inventory. However, I wasn't able to find Azure private IP property for Ansible.

Below is the code that I am using to fetch the private IP of remote host but Ansible is not fetching any private IP of remote host

- name: Create virtual network inteface card
  azure_rm_networkinterface:
    resource_group: apache-corp
    name: ansibleServerNIC
    virtual_network: ansibleServerVnet
    subnet: ansibleServerSubnet
    public_ip_name: ansibleServerPublicIP
    security_group: ansibleNetworkSecurityGroup
  register: network_interface

- name: show private_ip
  debug: "{{ network_interface.ip_configuration.private_ip_address }}"

Error that Ansible shows:

"msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'ip_configuration'\n\nT

Copyright License:
Author:「learning fun」,Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer.
Link to:https://stackoverflow.com/questions/55501209/not-able-to-get-azure-vm-private-ip-using-ansible

About “Not able to get Azure VM private IP using Ansible” questions

I am trying to write the Private IP address of virtual machine created by Ansible into host inventory. However, I wasn't able to find Azure private IP property for Ansible. Below is the code that ...
How can you get the private IP for a VM in am Azure scale set in Ansible? None of these seem to have the info: azure_rm_virtualmachinescaleset_facts azure_rm_virtualmachinescalesetinstance_facts
I want to get azure VM name from IP address, I tried following to get NIC name from IP and find to which VM that NIC is attached. Get-AzureRmNetworkInterface | ForEach { $Interface = $_.Name; $IPs...
Rewrite the Qusestion When I use azure_rm – Azure Resource Manager inventory plugin, how can I change the ssh user connecting to the Azure VM? The old Question I troubled that the Ansible in my ...
how to retain a private IP of a VM before deleting and use it for another VM I have provisioned a VM in azure with private IP and want to delete that VM which I provisioned and create a new VM with...
I'm new to ansible and I got a doubt the ansible ProxyCommand. I'm using it to connect to a couple of VMs in Azure with private IP only and it working fine, but every time I re-create my infra (Ter...
I'm new to Azure. Just deployed an Ubuntu VM but thought I'd only create a private IP address, no public IP. How do I ssh from my laptop at home to the Azure VM using the 10.x.x.x IP address? ...
We are trying to create and install packages on Azure using Ansible. We are able to create the instance using Ansible Azure module but we are stuck at installing the packages once the VM is created
Able to fetch details about VM from azure using object mentioned here: https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2021-03-01/[email protected]+incompatible#VirtualMach...
I'm trying to create a simple script to provision the machines in my Vagrant setup. I currently have a private network set up, where each node in the Vagrant file has something like: node.vm.ne...

Copyright License:Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer.