mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-27 04:41:26 -07:00
azure_rm_networkinterface: fixed issue when public ip address should not be created (#36824)
* fixed issue when public ip address should not be created * adding test for public ip address * fixed samples * another fix to sample formatting * fixed test * fix test * fixed test * another attempt to fix test * maybe it works now * still wrong * improved check per customer request * removed stupid semicolon * updated test to match main scenario * changed ip configurations to list * another attempt
This commit is contained in:
parent
fdc0e5c5fb
commit
89401f13f7
2 changed files with 67 additions and 47 deletions
|
@ -175,7 +175,7 @@ EXAMPLES = '''
|
||||||
virtual_network_name: vnet001
|
virtual_network_name: vnet001
|
||||||
subnet_name: subnet001
|
subnet_name: subnet001
|
||||||
ip_configurations:
|
ip_configurations:
|
||||||
name: ipconfig1
|
- name: ipconfig1
|
||||||
public_ip_address_name: publicip001
|
public_ip_address_name: publicip001
|
||||||
primary: True
|
primary: True
|
||||||
|
|
||||||
|
@ -186,7 +186,7 @@ EXAMPLES = '''
|
||||||
virtual_network_name: vnet001
|
virtual_network_name: vnet001
|
||||||
subnet_name: subnet001
|
subnet_name: subnet001
|
||||||
ip_configurations:
|
ip_configurations:
|
||||||
name: ipconfig1
|
- name: ipconfig1
|
||||||
primary: True
|
primary: True
|
||||||
|
|
||||||
- name: Create a network interface for use in a Windows host (opens RDP port) with custom RDP port
|
- name: Create a network interface for use in a Windows host (opens RDP port) with custom RDP port
|
||||||
|
@ -198,7 +198,7 @@ EXAMPLES = '''
|
||||||
os_type: Windows
|
os_type: Windows
|
||||||
rdp_port: 3399
|
rdp_port: 3399
|
||||||
ip_configurations:
|
ip_configurations:
|
||||||
name: ipconfig1
|
- name: ipconfig1
|
||||||
public_ip_address_name: publicip001
|
public_ip_address_name: publicip001
|
||||||
primary: True
|
primary: True
|
||||||
|
|
||||||
|
@ -210,7 +210,7 @@ EXAMPLES = '''
|
||||||
subnet_name: subnet001
|
subnet_name: subnet001
|
||||||
security_group_name: secgroup001
|
security_group_name: secgroup001
|
||||||
ip_configurations:
|
ip_configurations:
|
||||||
name: ipconfig1
|
- name: ipconfig1
|
||||||
public_ip_address_name: publicip001
|
public_ip_address_name: publicip001
|
||||||
primary: True
|
primary: True
|
||||||
|
|
||||||
|
@ -533,6 +533,10 @@ class AzureRMNetworkInterface(AzureRMModuleBase):
|
||||||
|
|
||||||
def get_or_create_public_ip_address(self, ip_config):
|
def get_or_create_public_ip_address(self, ip_config):
|
||||||
name = ip_config.get('public_ip_address_name')
|
name = ip_config.get('public_ip_address_name')
|
||||||
|
|
||||||
|
if not (self.public_ip and name):
|
||||||
|
return None
|
||||||
|
|
||||||
pip = self.get_public_ip_address(name)
|
pip = self.get_public_ip_address(name)
|
||||||
if not pip:
|
if not pip:
|
||||||
params = self.network_models.PublicIPAddress(
|
params = self.network_models.PublicIPAddress(
|
||||||
|
|
|
@ -134,6 +134,22 @@
|
||||||
- not output.state.ip_configuration
|
- not output.state.ip_configuration
|
||||||
- output.state.ip_configurations | length == 2
|
- output.state.ip_configurations | length == 2
|
||||||
|
|
||||||
|
- name: IP configuration without public IP
|
||||||
|
azure_rm_networkinterface:
|
||||||
|
resource_group: "{{ resource_group }}"
|
||||||
|
name: testnic001noip
|
||||||
|
security_group: testnic001
|
||||||
|
virtual_network: "{{ vn.state.id }}"
|
||||||
|
subnet: testnic001
|
||||||
|
ip_configurations:
|
||||||
|
- name: ipconfig1
|
||||||
|
primary: True
|
||||||
|
register: output
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- output.state.ip_configurations[0].public_ip_address == None
|
||||||
|
|
||||||
- name: Delete the NIC (check mode)
|
- name: Delete the NIC (check mode)
|
||||||
azure_rm_networkinterface:
|
azure_rm_networkinterface:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue