Hi guys. In our Azure environment, we create the network interface cards with static address. We don't care to what will be the address, but once it's defined, we don't want it changes. I believe that others companies maybe adopts the same practice, so would be very usefull if we could create a network interface card (using azure_rm_networkinterface module), setting the allocation method as "Static", without need to inform an IP address. I appreciate any effort in this way.
ISSUE TYPE
Feature Idea
COMPONENT NAME
azure.azcollection.azure_rm_networkinterface
ADDITIONAL INFORMATION
This code block below is unable to create a NIC (it raises an error, requiring to inform the IP address), but it would be great if it works.
Today, to create a NIC in our automation scripts, we need to do some checks, using a much more complex code like this:
- name: Checking if the NIC already exists
azure_rm_networkinterface_info:
resource_group: rg-ansible
name: vm-hostname-nic1
register: inet
check_mode: no
- name: Storing the IP address, when NIC already exists
set_fact: inet_ip="{{ inet.networkinterfaces[0].ip_configurations[0] }}"
when: inet.networkinterfaces[0] is defined
- name: Creating the NIC, when it not exists
azure_rm_networkinterface:
resource_group: rg-ansible
virtual_network:
name: vnet-ansible
resource_group: rg-ansible
subnet_name: sn-main
name: vm-hostname-nic1
create_with_security_group: False
ip_configurations:
- name: ipconfig1
primary: True
register: inet_new
when: inet_ip.private_ip_address is not defined
- name: Storing the IP address of newly created NIC
set_fact: inet_ip="{{ inet_new.state.ip_configurations[0] }}"
when: inet_new.state.ip_configurations[0] is defined
- name: Changing address allocation method to static
azure_rm_networkinterface:
resource_group: rg-ansible
virtual_network:
name: vnet-ansible
resource_group: rg-ansible
subnet_name: sn-main
name: vm-hostname-nic1
create_with_security_group: False
ip_configurations:
- name: ipconfig1
private_ip_allocation_method: Static
private_ip_address: "{{ inet_ip.private_ip_address }}"
primary: True
when: inet_ip.private_ip_address is defined
SUMMARY
Hi guys. In our Azure environment, we create the network interface cards with static address. We don't care to what will be the address, but once it's defined, we don't want it changes. I believe that others companies maybe adopts the same practice, so would be very usefull if we could create a network interface card (using azure_rm_networkinterface module), setting the allocation method as "Static", without need to inform an IP address. I appreciate any effort in this way.
ISSUE TYPE
COMPONENT NAME
azure.azcollection.azure_rm_networkinterface
ADDITIONAL INFORMATION
This code block below is unable to create a NIC (it raises an error, requiring to inform the IP address), but it would be great if it works.
Today, to create a NIC in our automation scripts, we need to do some checks, using a much more complex code like this: