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