2017-08-12 01:16:39 +02:00
|
|
|
- name: Create virtual network
|
|
|
|
azure_rm_virtualnetwork:
|
|
|
|
name: My_Virtual_Network
|
|
|
|
address_prefixes_cidr:
|
|
|
|
- 10.1.0.0/16
|
|
|
|
- 172.100.0.0/16
|
|
|
|
dns_servers:
|
|
|
|
- 127.0.0.1
|
|
|
|
- 127.0.0.3
|
|
|
|
tags:
|
|
|
|
testing: testing
|
|
|
|
delete: on-exit
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
|
2018-08-23 00:24:57 +02:00
|
|
|
- name: Create route table
|
|
|
|
azure_rm_routetable:
|
|
|
|
name: routetableforsubnet
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
register: route_table
|
|
|
|
|
2017-08-12 01:16:39 +02:00
|
|
|
- name: Remove subnet
|
|
|
|
azure_rm_subnet:
|
|
|
|
state: absent
|
|
|
|
name: foobar
|
|
|
|
virtual_network_name: My_Virtual_Network
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
|
|
|
|
- name: Catch invalid cidr
|
|
|
|
azure_rm_subnet:
|
|
|
|
name: foobar
|
|
|
|
virtual_network_name: My_Virtual_Network
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
address_prefix_cidr: "10.1.0/24"
|
|
|
|
register: output
|
|
|
|
ignore_errors: yes
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that: output.failed
|
|
|
|
|
|
|
|
- name: Add the subnet back
|
|
|
|
azure_rm_subnet:
|
|
|
|
name: foobar
|
|
|
|
virtual_network_name: My_Virtual_Network
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
address_prefix_cidr: "10.1.0.0/24"
|
|
|
|
register: output
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that: output.changed
|
|
|
|
|
2019-03-22 07:27:12 +01:00
|
|
|
- name: Add the subnet back (idempontent)
|
|
|
|
azure_rm_subnet:
|
|
|
|
name: foobar
|
|
|
|
virtual_network_name: My_Virtual_Network
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
register: output
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that: not output.changed
|
|
|
|
|
2017-08-12 01:16:39 +02:00
|
|
|
- name: Create network security group
|
|
|
|
azure_rm_securitygroup:
|
|
|
|
name: secgroupfoo
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
tags:
|
|
|
|
testing: testing
|
|
|
|
|
|
|
|
- name: Update the subnet
|
|
|
|
azure_rm_subnet:
|
|
|
|
name: foobar
|
|
|
|
virtual_network_name: My_Virtual_Network
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
address_prefix_cidr: "10.1.0.0/16"
|
|
|
|
security_group: secgroupfoo
|
2018-10-25 07:43:47 +02:00
|
|
|
service_endpoints:
|
|
|
|
- service: Microsoft.Sql
|
|
|
|
locations:
|
|
|
|
- eastus
|
|
|
|
- westus
|
2017-08-12 01:16:39 +02:00
|
|
|
tags:
|
|
|
|
testing: testing
|
|
|
|
delete: on-fini
|
|
|
|
|
|
|
|
- name: Should be idempotent
|
|
|
|
azure_rm_subnet:
|
|
|
|
name: foobar
|
|
|
|
virtual_network_name: My_Virtual_Network
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
address_prefix_cidr: "10.1.0.0/16"
|
2018-10-25 07:43:47 +02:00
|
|
|
service_endpoints:
|
|
|
|
- service: Microsoft.Sql
|
|
|
|
locations:
|
|
|
|
- eastus
|
|
|
|
- westus
|
2017-08-12 01:16:39 +02:00
|
|
|
tags:
|
|
|
|
testing: testing
|
|
|
|
delete: on-fini
|
|
|
|
register: output
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that: not output.changed
|
|
|
|
|
2018-05-24 03:45:29 +02:00
|
|
|
- name: Create network security group in another resource group
|
|
|
|
azure_rm_securitygroup:
|
|
|
|
name: secgroupfoo
|
|
|
|
resource_group: "{{ resource_group_secondary }}"
|
|
|
|
register: nsg
|
|
|
|
|
|
|
|
- name: Update the subnet
|
|
|
|
azure_rm_subnet:
|
|
|
|
name: foobar
|
|
|
|
virtual_network_name: My_Virtual_Network
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
address_prefix_cidr: "10.1.0.0/16"
|
2018-08-23 00:24:57 +02:00
|
|
|
route_table: "{{ route_table.id }}"
|
2018-05-24 03:45:29 +02:00
|
|
|
security_group:
|
|
|
|
name: secgroupfoo
|
|
|
|
resource_group: "{{ resource_group_secondary }}"
|
|
|
|
tags:
|
|
|
|
testing: testing
|
|
|
|
delete: on-fini
|
|
|
|
register: output
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- output.changed
|
|
|
|
- output.state.network_security_group.id == nsg.state.id
|
|
|
|
|
|
|
|
- name: Update the subnet (idempotent)
|
|
|
|
azure_rm_subnet:
|
|
|
|
name: foobar
|
|
|
|
virtual_network_name: My_Virtual_Network
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
address_prefix_cidr: "10.1.0.0/16"
|
|
|
|
security_group: "{{ nsg.state.id }}"
|
|
|
|
tags:
|
|
|
|
testing: testing
|
|
|
|
delete: on-fini
|
|
|
|
register: output
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that: not output.changed
|
|
|
|
|
2019-02-20 06:56:36 +01:00
|
|
|
- name: Get subnet facts
|
|
|
|
azure_rm_subnet_facts:
|
|
|
|
name: foobar
|
|
|
|
virtual_network_name: My_Virtual_Network
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
register: output
|
|
|
|
|
|
|
|
- debug:
|
|
|
|
var: output
|
|
|
|
- name: Assert that facts are returned
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- output.changed == False
|
|
|
|
- output.subnets[0]['id'] != None
|
|
|
|
- output.subnets[0]['resource_group'] != None
|
|
|
|
- output.subnets[0]['virtual_network_name'] != None
|
|
|
|
- output.subnets[0]['name'] != None
|
|
|
|
- output.subnets[0]['address_prefix_cidr'] != None
|
|
|
|
- output.subnets[0]['route_table'] != None
|
|
|
|
- output.subnets[0]['security_group'] != None
|
|
|
|
- output.subnets[0]['provisioning_state'] != None
|
|
|
|
|
2017-08-12 01:16:39 +02:00
|
|
|
- name: Remove subnet
|
|
|
|
azure_rm_subnet:
|
|
|
|
state: absent
|
|
|
|
name: foobar
|
|
|
|
virtual_network_name: My_Virtual_Network
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
|
2018-01-25 01:59:14 +01:00
|
|
|
- name: Remove subnet (idempotent)
|
|
|
|
azure_rm_subnet:
|
|
|
|
state: absent
|
|
|
|
name: foobar
|
|
|
|
virtual_network_name: My_Virtual_Network
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
register: output
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that: not output.changed
|
|
|
|
|
2017-08-12 01:16:39 +02:00
|
|
|
- name: Remove security group
|
|
|
|
azure_rm_securitygroup:
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
name: secgroupfoo
|
|
|
|
state: absent
|
|
|
|
|
|
|
|
- name: Remove virtual network
|
|
|
|
azure_rm_virtualnetwork:
|
|
|
|
name: My_Virtual_Network
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
state: absent
|