adding subnet service endpoints (#47549)
adding subnet service endpoints
This commit is contained in:
parent
d79b6c8406
commit
1724b633f2
2 changed files with 49 additions and 1 deletions
|
@ -68,6 +68,20 @@ options:
|
|||
- The str can be the name or resource id of the route table.
|
||||
- The dict can contains C(name) and C(resource_group) of the route_table.
|
||||
version_added: "2.7"
|
||||
service_endpoints:
|
||||
description:
|
||||
- An array of service endpoints.
|
||||
type: list
|
||||
suboptions:
|
||||
service:
|
||||
description:
|
||||
- The type of the endpoint service.
|
||||
required: True
|
||||
locations:
|
||||
description:
|
||||
- A list of locations.
|
||||
type: list
|
||||
version_added: "2.8"
|
||||
|
||||
extends_documentation_fragment:
|
||||
- azure
|
||||
|
@ -169,6 +183,8 @@ def subnet_to_dict(subnet):
|
|||
result['route_table']['id'] = subnet.route_table.id
|
||||
result['route_table']['name'] = id_keys['routeTables']
|
||||
result['route_table']['resource_group'] = id_keys['resourceGroups']
|
||||
if subnet.service_endpoints:
|
||||
result['service_endpoints'] = [{'service': item.service, 'locations': item.locations} for item in subnet.service_endpoints]
|
||||
return result
|
||||
|
||||
|
||||
|
@ -183,7 +199,10 @@ class AzureRMSubnet(AzureRMModuleBase):
|
|||
virtual_network_name=dict(type='str', required=True, aliases=['virtual_network']),
|
||||
address_prefix_cidr=dict(type='str', aliases=['address_prefix']),
|
||||
security_group=dict(type='raw', aliases=['security_group_name']),
|
||||
route_table=dict(type='raw')
|
||||
route_table=dict(type='raw'),
|
||||
service_endpoints=dict(
|
||||
type='list'
|
||||
)
|
||||
)
|
||||
|
||||
required_if = [
|
||||
|
@ -202,6 +221,7 @@ class AzureRMSubnet(AzureRMModuleBase):
|
|||
self.address_prefix_cidr = None
|
||||
self.security_group = None
|
||||
self.route_table = None
|
||||
self.service_endpoints = None
|
||||
|
||||
super(AzureRMSubnet, self).__init__(self.module_arg_spec,
|
||||
supports_check_mode=True,
|
||||
|
@ -257,6 +277,21 @@ class AzureRMSubnet(AzureRMModuleBase):
|
|||
changed = True
|
||||
results['route_table']['id'] = self.route_table
|
||||
self.log("CHANGED: subnet {0} route_table to {1}".format(self.name, route_table['name']))
|
||||
|
||||
if self.service_endpoints:
|
||||
oldd = {}
|
||||
for item in self.service_endpoints:
|
||||
name = item['service']
|
||||
oldd[name] = {'service': name, 'locations': item['locations'].sort()}
|
||||
newd = {}
|
||||
if 'service_endpoints' in results:
|
||||
for item in results['service_endpoints']:
|
||||
name = item['service']
|
||||
newd[name] = {'service': name, 'locations': item['locations'].sort()}
|
||||
if newd != oldd:
|
||||
changed = True
|
||||
results['service_endpoints'] = self.service_endpoints
|
||||
|
||||
elif self.state == 'absent':
|
||||
changed = True
|
||||
except CloudError:
|
||||
|
@ -291,6 +326,9 @@ class AzureRMSubnet(AzureRMModuleBase):
|
|||
if self.route_table:
|
||||
subnet.route_table = self.network_models.RouteTable(id=self.route_table)
|
||||
|
||||
if self.service_endpoints:
|
||||
subnet.service_endpoints = self.service_endpoints
|
||||
|
||||
self.results['state'] = self.create_or_update_subnet(subnet)
|
||||
elif self.state == 'absent' and changed:
|
||||
# delete subnet
|
||||
|
|
|
@ -62,6 +62,11 @@
|
|||
resource_group: "{{ resource_group }}"
|
||||
address_prefix_cidr: "10.1.0.0/16"
|
||||
security_group: secgroupfoo
|
||||
service_endpoints:
|
||||
- service: Microsoft.Sql
|
||||
locations:
|
||||
- eastus
|
||||
- westus
|
||||
tags:
|
||||
testing: testing
|
||||
delete: on-fini
|
||||
|
@ -73,6 +78,11 @@
|
|||
resource_group: "{{ resource_group }}"
|
||||
address_prefix_cidr: "10.1.0.0/16"
|
||||
security_group: secgroupfoo
|
||||
service_endpoints:
|
||||
- service: Microsoft.Sql
|
||||
locations:
|
||||
- eastus
|
||||
- westus
|
||||
tags:
|
||||
testing: testing
|
||||
delete: on-fini
|
||||
|
|
Loading…
Reference in a new issue