Fixes some NIC problems: create without nsg, support loadbalancer (#38643)

* add loadbalancer

* dict check nullable

* add default vallue when get list

* create backend addr pool

* fix the set

* fix to dict

* fix ideponement

* use param security group name when create

* nic can has no nsg

* add test

* fix

* fix

* fix

* add document

* add configuration

* fix

* fix

* remove all resources

* fix

* fix test

* add version added

* fix lint

* fix lint

* Fixes some NIC bugs (#39213)

* add loadbalancer

* dict check nullable

* add default vallue when get list

* create backend addr pool

* fix the set

* fix to dict

* fix ideponement

* use param security group name when create

* nic can has no nsg

* add test

* fix

* fix

* fix

* fix idemponet

* add document

* fix test

* add configuration

* fix

* fix

* remove all resources

* fix

* fix test

* add version added

* fix lint

* fix lint

* fix lint

* remove new feature and only submit bugfix

* remove useless test

* fix

* fix indent

* Update azure_rm_networkinterface.py

* fix comment

* support 3 types to specific name and resource group

* avoid test racing

* fix test

* add sample

* add resource id test
This commit is contained in:
Yuwei Zhou
2018-05-24 12:32:03 +08:00
committed by Jordan Borean
parent 4fbdc1a497
commit c95724fb0a
3 changed files with 186 additions and 70 deletions

View File

@@ -17,6 +17,40 @@
name: ansiblepip3
resource_group: '{{ resource_group }}'
- name: create load balancer with multiple parameters
azure_rm_loadbalancer:
resource_group: '{{ resource_group }}'
name: lbtestfromansible
frontend_ip_configurations:
- name: frontendipconf0
public_ip_address: ansiblepip3
backend_address_pools:
- name: backendaddrpool0
- name: backendaddrpool1
probes:
- name: prob0
port: 80
inbound_nat_pools:
- name: inboundnatpool0
frontend_ip_configuration_name: frontendipconf0
protocol: Tcp
frontend_port_range_start: 80
frontend_port_range_end: 81
backend_port: 8080
load_balancing_rules:
- name: lbrbalancingrule0
frontend_ip_configuration: frontendipconf0
backend_address_pool: backendaddrpool0
frontend_port: 80
backend_port: 80
probe: prob0
register: lb
- name: create public ip
azure_rm_publicipaddress:
name: ansiblepip3
resource_group: '{{ resource_group }}'
- name: Create NIC (check mode)
azure_rm_networkinterface:
resource_group: "{{ resource_group }}"
@@ -33,26 +67,28 @@
that:
- output.changed
- name: Create NIC using virtual_network_resource_group parameter
- name: Create NIC using virtual_network resource_group parameter
azure_rm_networkinterface:
resource_group: "{{ resource_group }}"
name: testnic001rg
virtual_network: testnic001
virtual_network_resource_group: "{{ resource_group_secondary }}"
virtual_network:
name: testnic001
resource_group: "{{ resource_group_secondary }}"
subnet: testnic001
public_ip_name: testnic001
public_ip_name: testnic001rg
public_ip_allocation_method: Static
security_group: testnic001
register: output
- name: Create NIC using virtual_network_resource_group parameter (idempotent)
- name: Create NIC using virtual_network resource_group parameter (idempotent)
azure_rm_networkinterface:
resource_group: "{{ resource_group }}"
name: testnic001rg
virtual_network: testnic001
virtual_network_resource_group: "{{ resource_group_secondary }}"
virtual_network:
name: testnic001
resource_group: "{{ resource_group_secondary }}"
subnet: testnic001
public_ip_name: testnic001
public_ip_name: testnic001rg
public_ip_allocation_method: Static
security_group: testnic001
register: output
@@ -66,7 +102,7 @@
resource_group: "{{ resource_group }}"
name: testnic001rg
state: absent
- name: Create NIC
azure_rm_networkinterface:
resource_group: "{{ resource_group }}"
@@ -75,7 +111,9 @@
subnet: testnic001
public_ip_name: testnic001
public_ip_allocation_method: Static
security_group: testnic001
security_group:
name: testnic002
resource_group: "{{ resource_group_secondary }}"
register: output
- assert:
@@ -87,7 +125,9 @@
azure_rm_networkinterface:
resource_group: "{{ resource_group }}"
name: testnic001
security_group: testnic001
security_group:
name: testnic002
resource_group: "{{ resource_group_secondary }}"
virtual_network: "{{ vn.state.id }}"
subnet: testnic001
ip_configurations:
@@ -110,7 +150,9 @@
azure_rm_networkinterface:
resource_group: "{{ resource_group }}"
name: testnic001
security_group: testnic001
security_group:
name: testnic002
resource_group: "{{ resource_group_secondary }}"
virtual_network: "{{ vn.state.id }}"
subnet: testnic001
ip_configurations:
@@ -122,6 +164,10 @@
public_ip_allocation_method: Static
- name: ipconfig1
public_ip_name: testnic003
load_balancer_backend_address_pools:
- "{{ lb.state.backend_address_pools[0].id }}"
- name: backendaddrpool1
load_balancer: lbtestfromansible
register: output
- assert:
@@ -129,12 +175,13 @@
- output.changed
- not output.state.ip_configuration
- output.state.ip_configurations | length == 3
- output.state.network_security_group.name == 'testnic002'
- name: Update the NIC with mutilple ip configurations (idempotent)
azure_rm_networkinterface:
resource_group: "{{ resource_group }}"
name: testnic001
security_group: testnic001
security_group: "{{ output.state.network_security_group.id }}"
virtual_network: "{{ vn.state.id }}"
subnet: testnic001
ip_configurations:
@@ -146,6 +193,10 @@
public_ip_allocation_method: Static
- name: ipconfig1
public_ip_name: testnic003
load_balancer_backend_address_pools:
- "{{ lb.state.backend_address_pools[0].id }}"
- name: backendaddrpool1
load_balancer: lbtestfromansible
register: output
- assert:
@@ -156,12 +207,18 @@
azure_rm_networkinterface:
resource_group: "{{ resource_group }}"
name: testnic001
security_group: testnic001
security_group:
name: testnic002
resource_group: "{{ resource_group_secondary }}"
virtual_network: "{{ vn.state.id }}"
subnet: testnic001
ip_configurations:
- name: ipconfig1
public_ip_name: testnic003
load_balancer_backend_address_pools:
- "{{ lb.state.backend_address_pools[0].id }}"
- name: backendaddrpool1
load_balancer: lbtestfromansible
- name: default
public_ip_name: testnic001
public_ip_allocation_method: Static
@@ -173,10 +230,11 @@
- not output.state.ip_configuration
- output.state.ip_configurations | length == 2
- name: IP configuration without public IP
- name: IP configuration without public IP and NSG
azure_rm_networkinterface:
resource_group: "{{ resource_group }}"
name: testnic001noip
create_with_security_group: False
virtual_network: "{{ vn.state.id }}"
subnet: testnic001
ip_configurations:
@@ -187,6 +245,7 @@
- assert:
that:
- output.state.ip_configurations[0].public_ip_address == None
- output.state.network_security_group == None
- name: Delete the NIC (check mode)
azure_rm_networkinterface: