mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 13:22:48 +00:00
more integration test improvements (#41184)
This commit is contained in:
committed by
Yunge Zhu
parent
5d7afe9d95
commit
e9214725fb
@@ -1,29 +1,34 @@
|
||||
- name: Prepare random number
|
||||
set_fact:
|
||||
rpfx: "{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
|
||||
run_once: yes
|
||||
|
||||
- name: Create virtual network
|
||||
azure_rm_virtualnetwork:
|
||||
resource_group: "{{ resource_group_secondary }}"
|
||||
name: testnic001
|
||||
name: "tn{{ rpfx }}"
|
||||
address_prefixes: "10.10.0.0/16"
|
||||
register: vn
|
||||
|
||||
- name: Add subnet
|
||||
azure_rm_subnet:
|
||||
resource_group: "{{ resource_group_secondary }}"
|
||||
name: testnic001
|
||||
name: "tn{{ rpfx }}"
|
||||
address_prefix: "10.10.0.0/24"
|
||||
virtual_network: testnic001
|
||||
virtual_network: "tn{{ rpfx }}"
|
||||
|
||||
- name: create public ip
|
||||
azure_rm_publicipaddress:
|
||||
name: ansiblepip3
|
||||
name: "pip{{ rpfx }}"
|
||||
resource_group: '{{ resource_group }}'
|
||||
|
||||
- name: create load balancer with multiple parameters
|
||||
azure_rm_loadbalancer:
|
||||
resource_group: '{{ resource_group }}'
|
||||
name: lbtestfromansible
|
||||
name: "lb{{ rpfx }}"
|
||||
frontend_ip_configurations:
|
||||
- name: frontendipconf0
|
||||
public_ip_address: ansiblepip3
|
||||
public_ip_address: "pip{{ rpfx }}"
|
||||
backend_address_pools:
|
||||
- name: backendaddrpool0
|
||||
- name: backendaddrpool1
|
||||
@@ -48,18 +53,18 @@
|
||||
|
||||
- name: create public ip
|
||||
azure_rm_publicipaddress:
|
||||
name: ansiblepip3
|
||||
name: "pip{{ rpfx }}"
|
||||
resource_group: '{{ resource_group }}'
|
||||
|
||||
- name: Create NIC (check mode)
|
||||
azure_rm_networkinterface:
|
||||
resource_group: "{{ resource_group }}"
|
||||
name: testnic001
|
||||
name: "tn{{ rpfx }}"
|
||||
virtual_network: "{{ vn.state.id }}"
|
||||
subnet: testnic001
|
||||
public_ip_name: testnic001
|
||||
subnet: "tn{{ rpfx }}"
|
||||
public_ip_name: "tn{{ rpfx }}"
|
||||
public_ip_allocation_method: Static
|
||||
security_group: testnic001
|
||||
security_group: "tn{{ rpfx }}"
|
||||
register: output
|
||||
check_mode: yes
|
||||
|
||||
@@ -70,27 +75,27 @@
|
||||
- name: Create NIC using virtual_network resource_group parameter
|
||||
azure_rm_networkinterface:
|
||||
resource_group: "{{ resource_group }}"
|
||||
name: testnic001rg
|
||||
name: "tn{{ rpfx }}rg"
|
||||
virtual_network:
|
||||
name: testnic001
|
||||
name: "tn{{ rpfx }}"
|
||||
resource_group: "{{ resource_group_secondary }}"
|
||||
subnet: testnic001
|
||||
public_ip_name: testnic001rg
|
||||
subnet: "tn{{ rpfx }}"
|
||||
public_ip_name: "tn{{ rpfx }}rg"
|
||||
public_ip_allocation_method: Static
|
||||
security_group: testnic001
|
||||
security_group: "tn{{ rpfx }}"
|
||||
register: output
|
||||
|
||||
- name: Create NIC using virtual_network resource_group parameter (idempotent)
|
||||
azure_rm_networkinterface:
|
||||
resource_group: "{{ resource_group }}"
|
||||
name: testnic001rg
|
||||
name: "tn{{ rpfx }}rg"
|
||||
virtual_network:
|
||||
name: testnic001
|
||||
name: "tn{{ rpfx }}"
|
||||
resource_group: "{{ resource_group_secondary }}"
|
||||
subnet: testnic001
|
||||
public_ip_name: testnic001rg
|
||||
subnet: "tn{{ rpfx }}"
|
||||
public_ip_name: "tn{{ rpfx }}rg"
|
||||
public_ip_allocation_method: Static
|
||||
security_group: testnic001
|
||||
security_group: "tn{{ rpfx }}"
|
||||
register: output
|
||||
|
||||
- assert:
|
||||
@@ -100,41 +105,41 @@
|
||||
- name: Delete NIC
|
||||
azure_rm_networkinterface:
|
||||
resource_group: "{{ resource_group }}"
|
||||
name: testnic001rg
|
||||
name: "tn{{ rpfx }}rg"
|
||||
state: absent
|
||||
|
||||
- name: Create NIC
|
||||
azure_rm_networkinterface:
|
||||
resource_group: "{{ resource_group }}"
|
||||
name: testnic001
|
||||
name: "tn{{ rpfx }}"
|
||||
virtual_network: "{{ vn.state.id }}"
|
||||
subnet: testnic001
|
||||
public_ip_name: testnic001
|
||||
subnet: "tn{{ rpfx }}"
|
||||
public_ip_name: "tn{{ rpfx }}"
|
||||
public_ip_allocation_method: Static
|
||||
security_group:
|
||||
name: testnic002
|
||||
name: "tn{{ rpfx }}2"
|
||||
resource_group: "{{ resource_group_secondary }}"
|
||||
register: output
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- output.changed
|
||||
- output.state.ip_configuration.subnet.name == 'testnic001'
|
||||
- output.state.ip_configuration.subnet.name == 'tn{{ rpfx }}'
|
||||
|
||||
- name: Update the NIC with mutilple ip configurations (check mode)
|
||||
azure_rm_networkinterface:
|
||||
resource_group: "{{ resource_group }}"
|
||||
name: testnic001
|
||||
name: "tn{{ rpfx }}"
|
||||
security_group:
|
||||
name: testnic002
|
||||
name: "tn{{ rpfx }}2"
|
||||
resource_group: "{{ resource_group_secondary }}"
|
||||
virtual_network: "{{ vn.state.id }}"
|
||||
subnet: testnic001
|
||||
subnet: "tn{{ rpfx }}"
|
||||
ip_configurations:
|
||||
- name: ipconfig-add
|
||||
public_ip_name: testnic002
|
||||
public_ip_name: "tn{{ rpfx }}2"
|
||||
- name: default
|
||||
public_ip_name: testnic001
|
||||
public_ip_name: "tn{{ rpfx }}"
|
||||
primary: True
|
||||
public_ip_allocation_method: Static
|
||||
- name: ipconfig1
|
||||
@@ -149,17 +154,17 @@
|
||||
- name: Update the NIC with mutilple ip configurations
|
||||
azure_rm_networkinterface:
|
||||
resource_group: "{{ resource_group }}"
|
||||
name: testnic001
|
||||
name: "tn{{ rpfx }}"
|
||||
security_group:
|
||||
name: testnic002
|
||||
name: "tn{{ rpfx }}2"
|
||||
resource_group: "{{ resource_group_secondary }}"
|
||||
virtual_network: "{{ vn.state.id }}"
|
||||
subnet: testnic001
|
||||
subnet: "tn{{ rpfx }}"
|
||||
ip_configurations:
|
||||
- name: ipconfig-add
|
||||
public_ip_name: testnic002
|
||||
public_ip_name: "tn{{ rpfx }}2"
|
||||
- name: default
|
||||
public_ip_name: testnic001
|
||||
public_ip_name: "tn{{ rpfx }}"
|
||||
primary: True
|
||||
public_ip_allocation_method: Static
|
||||
- name: ipconfig1
|
||||
@@ -167,7 +172,7 @@
|
||||
load_balancer_backend_address_pools:
|
||||
- "{{ lb.state.backend_address_pools[0].id }}"
|
||||
- name: backendaddrpool1
|
||||
load_balancer: lbtestfromansible
|
||||
load_balancer: "lb{{ rpfx }}"
|
||||
register: output
|
||||
|
||||
- assert:
|
||||
@@ -175,20 +180,20 @@
|
||||
- output.changed
|
||||
- not output.state.ip_configuration
|
||||
- output.state.ip_configurations | length == 3
|
||||
- output.state.network_security_group.name == 'testnic002'
|
||||
- output.state.network_security_group.name == 'tn{{ rpfx }}2'
|
||||
|
||||
- name: Update the NIC with mutilple ip configurations (idempotent)
|
||||
azure_rm_networkinterface:
|
||||
resource_group: "{{ resource_group }}"
|
||||
name: testnic001
|
||||
name: "tn{{ rpfx }}"
|
||||
security_group: "{{ output.state.network_security_group.id }}"
|
||||
virtual_network: "{{ vn.state.id }}"
|
||||
subnet: testnic001
|
||||
subnet: "tn{{ rpfx }}"
|
||||
ip_configurations:
|
||||
- name: ipconfig-add
|
||||
public_ip_name: testnic002
|
||||
public_ip_name: "tn{{ rpfx }}2"
|
||||
- name: default
|
||||
public_ip_name: testnic001
|
||||
public_ip_name: "tn{{ rpfx }}"
|
||||
primary: True
|
||||
public_ip_allocation_method: Static
|
||||
- name: ipconfig1
|
||||
@@ -196,7 +201,7 @@
|
||||
load_balancer_backend_address_pools:
|
||||
- "{{ lb.state.backend_address_pools[0].id }}"
|
||||
- name: backendaddrpool1
|
||||
load_balancer: lbtestfromansible
|
||||
load_balancer: "lb{{ rpfx }}"
|
||||
register: output
|
||||
|
||||
- assert:
|
||||
@@ -206,21 +211,21 @@
|
||||
- name: Remove one ip configuration
|
||||
azure_rm_networkinterface:
|
||||
resource_group: "{{ resource_group }}"
|
||||
name: testnic001
|
||||
name: "tn{{ rpfx }}"
|
||||
security_group:
|
||||
name: testnic002
|
||||
name: "tn{{ rpfx }}2"
|
||||
resource_group: "{{ resource_group_secondary }}"
|
||||
virtual_network: "{{ vn.state.id }}"
|
||||
subnet: testnic001
|
||||
subnet: "tn{{ rpfx }}"
|
||||
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
|
||||
load_balancer: "lb{{ rpfx }}"
|
||||
- name: default
|
||||
public_ip_name: testnic001
|
||||
public_ip_name: "tn{{ rpfx }}"
|
||||
public_ip_allocation_method: Static
|
||||
primary: True
|
||||
register: output
|
||||
@@ -233,10 +238,10 @@
|
||||
- name: IP configuration without public IP and NSG
|
||||
azure_rm_networkinterface:
|
||||
resource_group: "{{ resource_group }}"
|
||||
name: testnic001noip
|
||||
name: "tn{{ rpfx }}noip"
|
||||
create_with_security_group: False
|
||||
virtual_network: "{{ vn.state.id }}"
|
||||
subnet: testnic001
|
||||
subnet: "tn{{ rpfx }}"
|
||||
ip_configurations:
|
||||
- name: ipconfig1
|
||||
primary: True
|
||||
@@ -250,7 +255,7 @@
|
||||
- name: Delete the NIC (check mode)
|
||||
azure_rm_networkinterface:
|
||||
resource_group: "{{ resource_group }}"
|
||||
name: testnic001
|
||||
name: "tn{{ rpfx }}"
|
||||
state: absent
|
||||
check_mode: yes
|
||||
register: output
|
||||
@@ -265,8 +270,8 @@
|
||||
name: "{{ item }}"
|
||||
state: absent
|
||||
with_items:
|
||||
- testnic001
|
||||
- testnic001noip
|
||||
- "tn{{ rpfx }}"
|
||||
- "tn{{ rpfx }}noip"
|
||||
register: output
|
||||
|
||||
- assert:
|
||||
@@ -276,10 +281,45 @@
|
||||
- name: Delete the NIC (idempotent)
|
||||
azure_rm_networkinterface:
|
||||
resource_group: "{{ resource_group }}"
|
||||
name: testnic001
|
||||
name: "tn{{ rpfx }}"
|
||||
state: absent
|
||||
register: output
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- not output.changed
|
||||
- not output.changed
|
||||
|
||||
- name: delete load balancer
|
||||
azure_rm_loadbalancer:
|
||||
resource_group: '{{ resource_group }}'
|
||||
name: "lb{{ rpfx }}"
|
||||
frontend_ip_configurations:
|
||||
- name: frontendipconf0
|
||||
public_ip_address: "pip{{ rpfx }}"
|
||||
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
|
||||
state: absent
|
||||
|
||||
- name: delete public ip
|
||||
azure_rm_publicipaddress:
|
||||
name: "pip{{ rpfx }}"
|
||||
resource_group: '{{ resource_group }}'
|
||||
state: absent
|
||||
|
||||
Reference in New Issue
Block a user