2018-06-12 04:52:07 +02:00
|
|
|
- name: Prepare random number
|
|
|
|
set_fact:
|
|
|
|
rpfx: "{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
|
2019-02-21 10:23:09 +01:00
|
|
|
applicationsecuritygroup_name1: "asg{{ resource_group | hash('md5') | truncate(5, True, '') }}{{ 1000 | random }}"
|
|
|
|
applicationsecuritygroup_name2: "asg{{ resource_group | hash('md5') | truncate(5, True, '') }}{{ 1000 | random }}"
|
|
|
|
nic_name1: "nic1{{ resource_group | hash('md5') | truncate(5, True, '') }}{{ 1000 | random }}"
|
2018-06-12 04:52:07 +02:00
|
|
|
run_once: yes
|
|
|
|
|
2018-01-24 05:57:08 +01:00
|
|
|
- name: Create virtual network
|
|
|
|
azure_rm_virtualnetwork:
|
|
|
|
resource_group: "{{ resource_group_secondary }}"
|
2018-06-12 04:52:07 +02:00
|
|
|
name: "tn{{ rpfx }}"
|
2018-01-24 05:57:08 +01:00
|
|
|
address_prefixes: "10.10.0.0/16"
|
|
|
|
register: vn
|
|
|
|
|
|
|
|
- name: Add subnet
|
|
|
|
azure_rm_subnet:
|
|
|
|
resource_group: "{{ resource_group_secondary }}"
|
2018-06-12 04:52:07 +02:00
|
|
|
name: "tn{{ rpfx }}"
|
2018-01-24 05:57:08 +01:00
|
|
|
address_prefix: "10.10.0.0/24"
|
2018-06-12 04:52:07 +02:00
|
|
|
virtual_network: "tn{{ rpfx }}"
|
2018-01-24 05:57:08 +01:00
|
|
|
|
2018-04-25 03:54:19 +02:00
|
|
|
- name: create public ip
|
|
|
|
azure_rm_publicipaddress:
|
2018-06-12 04:52:07 +02:00
|
|
|
name: "pip{{ rpfx }}"
|
2018-04-25 03:54:19 +02:00
|
|
|
resource_group: '{{ resource_group }}'
|
|
|
|
|
2018-05-24 06:32:03 +02:00
|
|
|
- name: create load balancer with multiple parameters
|
|
|
|
azure_rm_loadbalancer:
|
|
|
|
resource_group: '{{ resource_group }}'
|
2018-06-12 04:52:07 +02:00
|
|
|
name: "lb{{ rpfx }}"
|
2018-05-24 06:32:03 +02:00
|
|
|
frontend_ip_configurations:
|
|
|
|
- name: frontendipconf0
|
2018-06-12 04:52:07 +02:00
|
|
|
public_ip_address: "pip{{ rpfx }}"
|
2018-05-24 06:32:03 +02:00
|
|
|
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
|
|
|
|
|
2019-01-14 07:17:31 +01:00
|
|
|
- name: Create most simple NIC with virtual_network id (check mode)
|
2018-01-24 05:57:08 +01:00
|
|
|
azure_rm_networkinterface:
|
|
|
|
resource_group: "{{ resource_group }}"
|
2018-06-12 04:52:07 +02:00
|
|
|
name: "tn{{ rpfx }}"
|
2018-01-24 05:57:08 +01:00
|
|
|
virtual_network: "{{ vn.state.id }}"
|
2018-06-12 04:52:07 +02:00
|
|
|
subnet: "tn{{ rpfx }}"
|
2019-01-14 07:17:31 +01:00
|
|
|
public_ip: False
|
|
|
|
create_with_security_group: False
|
2018-01-24 05:57:08 +01:00
|
|
|
register: output
|
|
|
|
check_mode: yes
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- output.changed
|
|
|
|
|
2019-01-14 07:17:31 +01:00
|
|
|
- name: Create most simple NIC with virtual_network resource_group
|
2018-03-22 03:10:29 +01:00
|
|
|
azure_rm_networkinterface:
|
|
|
|
resource_group: "{{ resource_group }}"
|
2019-01-14 07:17:31 +01:00
|
|
|
name: "tn{{ rpfx }}"
|
2018-05-24 06:32:03 +02:00
|
|
|
virtual_network:
|
2018-06-12 04:52:07 +02:00
|
|
|
name: "tn{{ rpfx }}"
|
2018-05-24 06:32:03 +02:00
|
|
|
resource_group: "{{ resource_group_secondary }}"
|
2018-06-12 04:52:07 +02:00
|
|
|
subnet: "tn{{ rpfx }}"
|
2019-01-14 07:17:31 +01:00
|
|
|
public_ip: False
|
|
|
|
create_with_security_group: False
|
2018-01-24 05:57:08 +01:00
|
|
|
register: output
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- output.changed
|
2019-01-14 07:17:31 +01:00
|
|
|
- output.state.id
|
2018-01-24 05:57:08 +01:00
|
|
|
|
2019-01-14 07:17:31 +01:00
|
|
|
- name: Get fact of the new created NIC
|
|
|
|
azure_rm_networkinterface_facts:
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
name: "tn{{ rpfx }}"
|
|
|
|
register: facts
|
2018-01-24 05:57:08 +01:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
2019-01-14 07:17:31 +01:00
|
|
|
- "facts.networkinterfaces | length == 1"
|
|
|
|
- facts.networkinterfaces[0].id == output.state.id
|
|
|
|
- "facts.networkinterfaces[0].ip_configurations | length == 1"
|
|
|
|
- not facts.networkinterfaces[0].security_group
|
|
|
|
- not facts.networkinterfaces[0].ip_configurations[0].public_ip_address
|
|
|
|
- not facts.networkinterfaces[0].enable_ip_forwarding
|
|
|
|
- not facts.networkinterfaces[0].enable_accelerated_networking
|
|
|
|
|
|
|
|
- name: Create most simple NIC with ip configurations (idempotent)
|
2018-01-24 05:57:08 +01:00
|
|
|
azure_rm_networkinterface:
|
2019-01-14 07:17:31 +01:00
|
|
|
resource_group: "{{ facts.networkinterfaces[0].resource_group }}"
|
|
|
|
name: "{{ facts.networkinterfaces[0].name }}"
|
|
|
|
virtual_network: "{{ facts.networkinterfaces[0].virtual_network }}"
|
|
|
|
create_with_security_group: False
|
2018-01-24 05:57:08 +01:00
|
|
|
ip_configurations:
|
2019-01-14 07:17:31 +01:00
|
|
|
- name: "{{ facts.networkinterfaces[0].ip_configurations[0].name }}"
|
|
|
|
private_ip_address: "{{ facts.networkinterfaces[0].ip_configurations[0].private_ip_address }}"
|
|
|
|
private_ip_allocation_method: "{{ facts.networkinterfaces[0].ip_configurations[0].private_ip_allocation_method }}"
|
|
|
|
primary: "{{ facts.networkinterfaces[0].ip_configurations[0].primary }}"
|
|
|
|
subnet: "{{ facts.networkinterfaces[0].subnet }}"
|
2018-01-24 05:57:08 +01:00
|
|
|
register: output
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
2019-01-14 07:17:31 +01:00
|
|
|
- not output.changed
|
2018-01-24 05:57:08 +01:00
|
|
|
|
2019-01-14 07:17:31 +01:00
|
|
|
- name: Create most simple NIC (idempotent)
|
2018-01-24 05:57:08 +01:00
|
|
|
azure_rm_networkinterface:
|
|
|
|
resource_group: "{{ resource_group }}"
|
2018-06-12 04:52:07 +02:00
|
|
|
name: "tn{{ rpfx }}"
|
2018-01-24 05:57:08 +01:00
|
|
|
virtual_network: "{{ vn.state.id }}"
|
2018-06-12 04:52:07 +02:00
|
|
|
subnet: "tn{{ rpfx }}"
|
2019-01-14 07:17:31 +01:00
|
|
|
create_with_security_group: False
|
|
|
|
public_ip: False
|
2018-01-24 05:57:08 +01:00
|
|
|
register: output
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- not output.changed
|
|
|
|
|
2019-01-14 07:17:31 +01:00
|
|
|
- name: Update security group (check mode)
|
2018-01-24 05:57:08 +01:00
|
|
|
azure_rm_networkinterface:
|
|
|
|
resource_group: "{{ resource_group }}"
|
2018-06-12 04:52:07 +02:00
|
|
|
name: "tn{{ rpfx }}"
|
2018-01-24 05:57:08 +01:00
|
|
|
virtual_network: "{{ vn.state.id }}"
|
2018-06-12 04:52:07 +02:00
|
|
|
subnet: "tn{{ rpfx }}"
|
2019-01-14 07:17:31 +01:00
|
|
|
public_ip: False
|
|
|
|
security_group: "tn{{ rpfx }}sg"
|
2018-01-24 05:57:08 +01:00
|
|
|
register: output
|
2019-01-14 07:17:31 +01:00
|
|
|
check_mode: yes
|
2018-01-24 05:57:08 +01:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
2019-01-14 07:17:31 +01:00
|
|
|
- output.changed
|
2018-01-24 05:57:08 +01:00
|
|
|
|
2019-01-14 07:17:31 +01:00
|
|
|
- name: Update public ip address (check mode)
|
2018-03-22 00:16:32 +01:00
|
|
|
azure_rm_networkinterface:
|
|
|
|
resource_group: "{{ resource_group }}"
|
2019-01-14 07:17:31 +01:00
|
|
|
name: "tn{{ rpfx }}"
|
2018-03-22 00:16:32 +01:00
|
|
|
virtual_network: "{{ vn.state.id }}"
|
2018-06-12 04:52:07 +02:00
|
|
|
subnet: "tn{{ rpfx }}"
|
2019-01-14 07:17:31 +01:00
|
|
|
public_ip_address_name: "tn{{ rpfx }}"
|
|
|
|
create_with_security_group: False
|
2018-03-22 00:16:32 +01:00
|
|
|
register: output
|
2019-01-14 07:17:31 +01:00
|
|
|
check_mode: yes
|
2018-03-22 00:16:32 +01:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
2019-01-14 07:17:31 +01:00
|
|
|
- output.changed
|
2018-03-22 00:16:32 +01:00
|
|
|
|
2019-01-14 07:17:31 +01:00
|
|
|
- name: Update accelerated networking (check mode)
|
2018-07-27 08:56:36 +02:00
|
|
|
azure_rm_networkinterface:
|
|
|
|
resource_group: "{{ resource_group }}"
|
2019-01-14 07:17:31 +01:00
|
|
|
name: "tn{{ rpfx }}"
|
2018-07-27 08:56:36 +02:00
|
|
|
virtual_network: "{{ vn.state.id }}"
|
|
|
|
subnet: "tn{{ rpfx }}"
|
|
|
|
enable_accelerated_networking: True
|
2019-01-14 07:17:31 +01:00
|
|
|
create_with_security_group: False
|
|
|
|
public_ip: False
|
2018-07-27 08:56:36 +02:00
|
|
|
register: output
|
2019-01-14 07:17:31 +01:00
|
|
|
check_mode: yes
|
2018-07-27 08:56:36 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- output.changed
|
|
|
|
|
2019-01-14 07:17:31 +01:00
|
|
|
- name: Update IP forwarding networking (check mode)
|
2018-07-27 08:56:36 +02:00
|
|
|
azure_rm_networkinterface:
|
|
|
|
resource_group: "{{ resource_group }}"
|
2019-01-14 07:17:31 +01:00
|
|
|
name: "tn{{ rpfx }}"
|
2018-07-27 08:56:36 +02:00
|
|
|
virtual_network: "{{ vn.state.id }}"
|
|
|
|
subnet: "tn{{ rpfx }}"
|
2019-01-14 07:17:31 +01:00
|
|
|
create_with_security_group: False
|
|
|
|
enable_ip_forwarding: True
|
|
|
|
public_ip: False
|
2018-07-27 08:56:36 +02:00
|
|
|
register: output
|
2019-01-14 07:17:31 +01:00
|
|
|
check_mode: yes
|
2018-07-27 08:56:36 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
2019-01-14 07:17:31 +01:00
|
|
|
- output.changed
|
2018-07-27 08:56:36 +02:00
|
|
|
|
2019-01-14 07:17:31 +01:00
|
|
|
- name: Update dns server (check mode)
|
2018-07-27 08:56:36 +02:00
|
|
|
azure_rm_networkinterface:
|
|
|
|
resource_group: "{{ resource_group }}"
|
2019-01-14 07:17:31 +01:00
|
|
|
name: "tn{{ rpfx }}"
|
2018-07-27 08:56:36 +02:00
|
|
|
virtual_network: "{{ vn.state.id }}"
|
|
|
|
subnet: "tn{{ rpfx }}"
|
2019-01-14 07:17:31 +01:00
|
|
|
create_with_security_group: False
|
|
|
|
public_ip: False
|
|
|
|
dns_servers:
|
|
|
|
- 8.9.10.11
|
|
|
|
- 7.8.9.10
|
2018-08-10 23:14:48 +02:00
|
|
|
register: output
|
2019-01-14 07:17:31 +01:00
|
|
|
check_mode: yes
|
2018-08-10 23:14:48 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- output.changed
|
2018-07-27 08:56:36 +02:00
|
|
|
|
2019-01-14 07:17:31 +01:00
|
|
|
- name: Update NIC
|
2018-08-28 17:59:45 +02:00
|
|
|
azure_rm_networkinterface:
|
|
|
|
resource_group: "{{ resource_group }}"
|
2019-01-14 07:17:31 +01:00
|
|
|
name: "tn{{ rpfx }}"
|
2018-08-28 17:59:45 +02:00
|
|
|
virtual_network: "{{ vn.state.id }}"
|
|
|
|
subnet: "tn{{ rpfx }}"
|
2019-01-14 07:17:31 +01:00
|
|
|
enable_accelerated_networking: True
|
|
|
|
enable_ip_forwarding: True
|
|
|
|
security_group: "tn{{ rpfx }}sg"
|
2018-08-28 17:59:45 +02:00
|
|
|
dns_servers:
|
|
|
|
- 8.9.10.11
|
2019-01-14 07:17:31 +01:00
|
|
|
- 7.8.9.10
|
|
|
|
ip_configurations:
|
|
|
|
- name: "{{ facts.networkinterfaces[0].ip_configurations[0].name }}"
|
|
|
|
private_ip_address: "{{ facts.networkinterfaces[0].ip_configurations[0].private_ip_address }}"
|
|
|
|
private_ip_allocation_method: "{{ facts.networkinterfaces[0].ip_configurations[0].private_ip_allocation_method }}"
|
|
|
|
primary: "{{ facts.networkinterfaces[0].ip_configurations[0].primary }}"
|
|
|
|
- name: ipconfig1
|
|
|
|
public_ip_name: "tn{{ rpfx }}"
|
|
|
|
load_balancer_backend_address_pools:
|
|
|
|
- "{{ lb.state.backend_address_pools[0].id }}"
|
|
|
|
- name: backendaddrpool1
|
|
|
|
load_balancer: "lb{{ rpfx }}"
|
2018-08-28 17:59:45 +02:00
|
|
|
register: output
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- output.changed
|
2019-01-14 07:17:31 +01:00
|
|
|
- output.state.dns_settings.dns_servers == ['8.9.10.11', '7.8.9.10']
|
|
|
|
- output.state.enable_ip_forwarding
|
|
|
|
- output.state.network_security_group.name == "tn{{ rpfx }}sg"
|
|
|
|
- output.state.enable_accelerated_networking
|
2018-08-28 17:59:45 +02:00
|
|
|
|
2019-01-14 07:17:31 +01:00
|
|
|
- name: Complicated NIC (idempontent)
|
2018-08-28 17:59:45 +02:00
|
|
|
azure_rm_networkinterface:
|
|
|
|
resource_group: "{{ resource_group }}"
|
2019-01-14 07:17:31 +01:00
|
|
|
name: "tn{{ rpfx }}"
|
2018-08-28 17:59:45 +02:00
|
|
|
virtual_network: "{{ vn.state.id }}"
|
|
|
|
subnet: "tn{{ rpfx }}"
|
2019-01-14 07:17:31 +01:00
|
|
|
enable_accelerated_networking: True
|
|
|
|
security_group: "tn{{ rpfx }}sg"
|
|
|
|
enable_ip_forwarding: True
|
2018-08-28 17:59:45 +02:00
|
|
|
dns_servers:
|
|
|
|
- 8.9.10.11
|
2019-01-14 07:17:31 +01:00
|
|
|
- 7.8.9.10
|
|
|
|
ip_configurations:
|
|
|
|
- name: "{{ facts.networkinterfaces[0].ip_configurations[0].name }}"
|
|
|
|
private_ip_address: "{{ facts.networkinterfaces[0].ip_configurations[0].private_ip_address }}"
|
|
|
|
private_ip_allocation_method: "{{ facts.networkinterfaces[0].ip_configurations[0].private_ip_allocation_method }}"
|
|
|
|
primary: "{{ facts.networkinterfaces[0].ip_configurations[0].primary }}"
|
|
|
|
- name: ipconfig1
|
|
|
|
public_ip_name: "tn{{ rpfx }}"
|
|
|
|
load_balancer_backend_address_pools:
|
|
|
|
- "{{ lb.state.backend_address_pools[0].id }}"
|
|
|
|
- name: backendaddrpool1
|
|
|
|
load_balancer: "lb{{ rpfx }}"
|
2018-08-28 17:59:45 +02:00
|
|
|
register: output
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- not output.changed
|
|
|
|
|
2019-01-14 07:17:31 +01:00
|
|
|
- name: Get fact of the new created NIC
|
|
|
|
azure_rm_networkinterface_facts:
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
name: "tn{{ rpfx }}"
|
|
|
|
register: facts
|
2018-08-28 17:59:45 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
2019-01-14 07:17:31 +01:00
|
|
|
- "facts.networkinterfaces | length == 1"
|
|
|
|
- facts.networkinterfaces[0].id == output.state.id
|
|
|
|
- "facts.networkinterfaces[0].ip_configurations | length == 2"
|
|
|
|
- 'facts.networkinterfaces[0].security_group.endswith("tn{{ rpfx }}sg")'
|
|
|
|
- facts.networkinterfaces[0].enable_accelerated_networking
|
|
|
|
- facts.networkinterfaces[0].enable_ip_forwarding
|
|
|
|
|
|
|
|
- name: Remove one dns server and ip configuration
|
2018-08-28 17:59:45 +02:00
|
|
|
azure_rm_networkinterface:
|
|
|
|
resource_group: "{{ resource_group }}"
|
2019-01-14 07:17:31 +01:00
|
|
|
name: "tn{{ rpfx }}"
|
2018-08-28 17:59:45 +02:00
|
|
|
virtual_network: "{{ vn.state.id }}"
|
|
|
|
subnet: "tn{{ rpfx }}"
|
2019-01-14 07:17:31 +01:00
|
|
|
security_group: "tn{{ rpfx }}sg"
|
|
|
|
enable_accelerated_networking: True
|
|
|
|
enable_ip_forwarding: True
|
2018-08-28 17:59:45 +02:00
|
|
|
dns_servers:
|
2019-01-14 07:17:31 +01:00
|
|
|
- 8.9.10.11
|
|
|
|
ip_configurations:
|
|
|
|
- name: ipconfig1
|
|
|
|
public_ip_name: "tn{{ rpfx }}"
|
|
|
|
primary: True
|
|
|
|
load_balancer_backend_address_pools:
|
|
|
|
- "{{ lb.state.backend_address_pools[0].id }}"
|
|
|
|
- name: backendaddrpool1
|
|
|
|
load_balancer: "lb{{ rpfx }}"
|
2018-08-28 17:59:45 +02:00
|
|
|
register: output
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- output.changed
|
2019-01-14 07:17:31 +01:00
|
|
|
- output.state.dns_settings.dns_servers == ['8.9.10.11']
|
|
|
|
- output.state.enable_ip_forwarding
|
|
|
|
- output.state.network_security_group.name == "tn{{ rpfx }}sg"
|
|
|
|
- "output.state.ip_configurations | length == 1"
|
|
|
|
- output.state.ip_configurations[0].public_ip_address.name == "tn{{ rpfx }}"
|
|
|
|
- output.state.enable_accelerated_networking
|
2018-08-28 17:59:45 +02:00
|
|
|
|
2019-02-21 10:23:09 +01:00
|
|
|
- name: Create application security group(check mode)
|
|
|
|
azure_rm_applicationsecuritygroup:
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
name: "{{ applicationsecuritygroup_name1 }}"
|
|
|
|
tags:
|
|
|
|
testing: testing
|
|
|
|
check_mode: yes
|
|
|
|
register: output
|
|
|
|
|
|
|
|
- name: Assert check mode creation
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- output.changed
|
|
|
|
|
|
|
|
- name: Create Application security group
|
|
|
|
azure_rm_applicationsecuritygroup:
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
name: "{{ applicationsecuritygroup_name1 }}"
|
|
|
|
tags:
|
|
|
|
testing: testing
|
|
|
|
register: output
|
|
|
|
|
|
|
|
- name: Assert application security group creation
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- output.changed
|
|
|
|
- output.id != ''
|
|
|
|
|
2019-02-22 09:11:24 +01:00
|
|
|
- name: Get Application security group
|
|
|
|
azure_rm_applicationsecuritygroup_facts:
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
name: "{{ applicationsecuritygroup_name1 }}"
|
|
|
|
register: facts
|
|
|
|
|
|
|
|
- name: Assert facts
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- facts['applicationsecuritygroups'] | length == 1
|
|
|
|
- facts['applicationsecuritygroups'][0]['name'] != None
|
|
|
|
- facts['applicationsecuritygroups'][0]['location'] != None
|
|
|
|
- facts['applicationsecuritygroups'][0]['provisioning_state'] != None
|
|
|
|
|
2019-02-21 10:23:09 +01:00
|
|
|
- name: Create application security group (idempotent)
|
|
|
|
azure_rm_applicationsecuritygroup:
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
name: "{{ applicationsecuritygroup_name1 }}"
|
|
|
|
tags:
|
|
|
|
testing: testing
|
|
|
|
register: output
|
|
|
|
|
|
|
|
- name: Assert idempotent
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- not output.changed
|
|
|
|
|
|
|
|
- name: Update application security group
|
|
|
|
azure_rm_applicationsecuritygroup:
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
name: "{{ applicationsecuritygroup_name1 }}"
|
|
|
|
tags:
|
|
|
|
testing: testing
|
|
|
|
foo: bar
|
|
|
|
register: output
|
|
|
|
|
|
|
|
- name: Assert update
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- output.changed
|
|
|
|
|
|
|
|
- name: Create Application security group in secondary resource group
|
|
|
|
azure_rm_applicationsecuritygroup:
|
|
|
|
resource_group: "{{ resource_group_secondary }}"
|
|
|
|
name: "{{ applicationsecuritygroup_name2 }}"
|
|
|
|
register: asg
|
|
|
|
|
|
|
|
- name: Create Nic with application security groups
|
|
|
|
azure_rm_networkinterface:
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
name: "{{ nic_name1 }}"
|
|
|
|
virtual_network: "{{ vn.state.id }}"
|
|
|
|
subnet: "tn{{ rpfx }}"
|
|
|
|
create_with_security_group: True
|
|
|
|
public_ip: False
|
|
|
|
ip_configurations:
|
|
|
|
- name: ipconfig1
|
|
|
|
application_security_groups:
|
|
|
|
- "{{ applicationsecuritygroup_name1 }}"
|
|
|
|
- "{{ asg.id }}"
|
|
|
|
primary: True
|
|
|
|
register: output
|
|
|
|
|
|
|
|
- name: assert creation succeeded
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- output.changed
|
|
|
|
|
|
|
|
- name: Create Nic with application security groups (idempotent)
|
|
|
|
azure_rm_networkinterface:
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
name: "{{ nic_name1 }}"
|
|
|
|
virtual_network: "{{ vn.state.id }}"
|
|
|
|
subnet: "tn{{ rpfx }}"
|
|
|
|
create_with_security_group: True
|
|
|
|
public_ip: False
|
|
|
|
ip_configurations:
|
|
|
|
- name: ipconfig1
|
|
|
|
application_security_groups:
|
|
|
|
- "{{ asg.id }}"
|
|
|
|
- "{{ applicationsecuritygroup_name1 }}"
|
|
|
|
primary: True
|
|
|
|
register: output
|
|
|
|
|
|
|
|
- name: assert idempotent
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- not output.changed
|
|
|
|
|
|
|
|
- name: Update Nic with application security groups
|
|
|
|
azure_rm_networkinterface:
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
name: "{{ nic_name1 }}"
|
|
|
|
virtual_network: "{{ vn.state.id }}"
|
|
|
|
subnet: "tn{{ rpfx }}"
|
|
|
|
create_with_security_group: True
|
|
|
|
public_ip: False
|
|
|
|
ip_configurations:
|
|
|
|
- name: ipconfig1
|
|
|
|
application_security_groups:
|
|
|
|
- "{{ applicationsecuritygroup_name1 }}"
|
|
|
|
primary: True
|
|
|
|
register: output
|
|
|
|
|
|
|
|
- name: assert update succeeded
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- output.changed
|
|
|
|
|
|
|
|
- name: Get fact of the new created NIC
|
|
|
|
azure_rm_networkinterface_facts:
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
name: "{{ nic_name1 }}"
|
|
|
|
register: facts
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "facts.networkinterfaces[0].ip_configurations[0].application_security_groups | length == 1"
|
|
|
|
|
2018-01-24 05:57:08 +01:00
|
|
|
- name: Delete the NIC (check mode)
|
|
|
|
azure_rm_networkinterface:
|
|
|
|
resource_group: "{{ resource_group }}"
|
2018-06-12 04:52:07 +02:00
|
|
|
name: "tn{{ rpfx }}"
|
2018-01-24 05:57:08 +01:00
|
|
|
state: absent
|
|
|
|
check_mode: yes
|
|
|
|
register: output
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- output.changed
|
|
|
|
|
|
|
|
- name: Delete the NIC
|
|
|
|
azure_rm_networkinterface:
|
|
|
|
resource_group: "{{ resource_group }}"
|
2019-01-14 07:17:31 +01:00
|
|
|
name: "tn{{ rpfx }}"
|
2018-01-24 05:57:08 +01:00
|
|
|
state: absent
|
|
|
|
register: output
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- output.changed
|
|
|
|
|
|
|
|
- name: Delete the NIC (idempotent)
|
|
|
|
azure_rm_networkinterface:
|
|
|
|
resource_group: "{{ resource_group }}"
|
2018-06-12 04:52:07 +02:00
|
|
|
name: "tn{{ rpfx }}"
|
2018-01-24 05:57:08 +01:00
|
|
|
state: absent
|
|
|
|
register: output
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
2018-06-12 04:52:07 +02:00
|
|
|
- not output.changed
|
|
|
|
|
|
|
|
- name: delete load balancer
|
|
|
|
azure_rm_loadbalancer:
|
|
|
|
resource_group: '{{ resource_group }}'
|
|
|
|
name: "lb{{ rpfx }}"
|
|
|
|
state: absent
|
|
|
|
|
|
|
|
- name: delete public ip
|
|
|
|
azure_rm_publicipaddress:
|
|
|
|
name: "pip{{ rpfx }}"
|
|
|
|
resource_group: '{{ resource_group }}'
|
|
|
|
state: absent
|
2019-02-21 10:23:09 +01:00
|
|
|
|
|
|
|
- name: Delete the NIC
|
|
|
|
azure_rm_networkinterface:
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
name: "{{ nic_name1 }}"
|
|
|
|
state: absent
|
|
|
|
|
|
|
|
- name: Delete the application security group (check mode)
|
|
|
|
azure_rm_applicationsecuritygroup:
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
name: "{{ applicationsecuritygroup_name1 }}"
|
|
|
|
state: absent
|
|
|
|
check_mode: yes
|
|
|
|
register: output
|
|
|
|
|
|
|
|
- name: Assert delete check mode
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- output.changed
|
|
|
|
|
|
|
|
- name: Delete the application security group
|
|
|
|
azure_rm_applicationsecuritygroup:
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
name: "{{ applicationsecuritygroup_name1 }}"
|
|
|
|
state: absent
|
|
|
|
register: output
|
|
|
|
|
|
|
|
- name: Assert the deletion
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- output.changed
|
|
|
|
|
|
|
|
- name: Delete second application security group
|
|
|
|
azure_rm_applicationsecuritygroup:
|
|
|
|
resource_group: "{{ resource_group_secondary }}"
|
|
|
|
name: "{{ applicationsecuritygroup_name2 }}"
|
|
|
|
state: absent
|
|
|
|
register: output
|