|
|
@ -82,6 +82,79 @@ azure_virtualnetworks:
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"type": "Microsoft.Network/virtualNetworks"
|
|
|
|
"type": "Microsoft.Network/virtualNetworks"
|
|
|
|
}]
|
|
|
|
}]
|
|
|
|
|
|
|
|
virtualnetworks:
|
|
|
|
|
|
|
|
description: List of virtual network dicts with same format as azure_rm_virtualnetwork module parameters.
|
|
|
|
|
|
|
|
returned: always
|
|
|
|
|
|
|
|
type: list
|
|
|
|
|
|
|
|
contains:
|
|
|
|
|
|
|
|
id:
|
|
|
|
|
|
|
|
description:
|
|
|
|
|
|
|
|
- Resource ID.
|
|
|
|
|
|
|
|
sample: /subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX/resourceGroups/Testing/providers/Microsoft.Network/virtualNetworks/vnet2001
|
|
|
|
|
|
|
|
type: str
|
|
|
|
|
|
|
|
address_prefixes:
|
|
|
|
|
|
|
|
description:
|
|
|
|
|
|
|
|
- List of IPv4 address ranges where each is formatted using CIDR notation.
|
|
|
|
|
|
|
|
sample: ["10.10.0.0/16"]
|
|
|
|
|
|
|
|
type: list
|
|
|
|
|
|
|
|
dns_servers:
|
|
|
|
|
|
|
|
description:
|
|
|
|
|
|
|
|
- Custom list of DNS servers.
|
|
|
|
|
|
|
|
type: list
|
|
|
|
|
|
|
|
sample: ["www.azure.com"]
|
|
|
|
|
|
|
|
location:
|
|
|
|
|
|
|
|
description:
|
|
|
|
|
|
|
|
- Valid azure location.
|
|
|
|
|
|
|
|
type: str
|
|
|
|
|
|
|
|
sample: eastus
|
|
|
|
|
|
|
|
tags:
|
|
|
|
|
|
|
|
description:
|
|
|
|
|
|
|
|
- Tags assigned to the resource. Dictionary of string:string pairs.
|
|
|
|
|
|
|
|
type: dict
|
|
|
|
|
|
|
|
sample: { "tag1": "abc" }
|
|
|
|
|
|
|
|
provisioning_state:
|
|
|
|
|
|
|
|
description:
|
|
|
|
|
|
|
|
- Provisioning state of the resource.
|
|
|
|
|
|
|
|
sample: Successed
|
|
|
|
|
|
|
|
type: str
|
|
|
|
|
|
|
|
name:
|
|
|
|
|
|
|
|
description:
|
|
|
|
|
|
|
|
- name of the virtual network.
|
|
|
|
|
|
|
|
type: str
|
|
|
|
|
|
|
|
sample: foo
|
|
|
|
|
|
|
|
subnets:
|
|
|
|
|
|
|
|
description:
|
|
|
|
|
|
|
|
- Subnets associate to this virtual network.
|
|
|
|
|
|
|
|
type: list
|
|
|
|
|
|
|
|
contains:
|
|
|
|
|
|
|
|
id:
|
|
|
|
|
|
|
|
description:
|
|
|
|
|
|
|
|
- Resource ID.
|
|
|
|
|
|
|
|
type: str
|
|
|
|
|
|
|
|
name:
|
|
|
|
|
|
|
|
description:
|
|
|
|
|
|
|
|
- Resource Name.
|
|
|
|
|
|
|
|
type: str
|
|
|
|
|
|
|
|
provisioning_state:
|
|
|
|
|
|
|
|
description:
|
|
|
|
|
|
|
|
- provision state of the Resource.
|
|
|
|
|
|
|
|
type: str
|
|
|
|
|
|
|
|
sample: Successed
|
|
|
|
|
|
|
|
address_prefix:
|
|
|
|
|
|
|
|
description:
|
|
|
|
|
|
|
|
- The address prefix for the subnet.
|
|
|
|
|
|
|
|
network_security_group:
|
|
|
|
|
|
|
|
description:
|
|
|
|
|
|
|
|
- Existing security group id with which to associate the subnet.
|
|
|
|
|
|
|
|
type: str
|
|
|
|
|
|
|
|
route_table:
|
|
|
|
|
|
|
|
description:
|
|
|
|
|
|
|
|
- The reference of the RouteTable resource.
|
|
|
|
|
|
|
|
type: str
|
|
|
|
|
|
|
|
service_endpoints:
|
|
|
|
|
|
|
|
description:
|
|
|
|
|
|
|
|
- An array of service endpoints.
|
|
|
|
|
|
|
|
type: list
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
@ -108,7 +181,8 @@ class AzureRMNetworkInterfaceFacts(AzureRMModuleBase):
|
|
|
|
|
|
|
|
|
|
|
|
self.results = dict(
|
|
|
|
self.results = dict(
|
|
|
|
changed=False,
|
|
|
|
changed=False,
|
|
|
|
ansible_facts=dict(azure_virtualnetworks=[])
|
|
|
|
ansible_facts=dict(azure_virtualnetworks=[]),
|
|
|
|
|
|
|
|
virtualnetworks=[]
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
self.name = None
|
|
|
|
self.name = None
|
|
|
@ -125,9 +199,14 @@ class AzureRMNetworkInterfaceFacts(AzureRMModuleBase):
|
|
|
|
setattr(self, key, kwargs[key])
|
|
|
|
setattr(self, key, kwargs[key])
|
|
|
|
|
|
|
|
|
|
|
|
if self.name is not None:
|
|
|
|
if self.name is not None:
|
|
|
|
self.results['ansible_facts']['azure_virtualnetworks'] = self.get_item()
|
|
|
|
results = self.get_item()
|
|
|
|
|
|
|
|
elif self.resource_group is not None:
|
|
|
|
|
|
|
|
results = self.list_resource_group()
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
self.results['ansible_facts']['azure_virtualnetworks'] = self.list_items()
|
|
|
|
results = self.list_items()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.results['ansible_facts']['azure_virtualnetworks'] = self.serialize(results)
|
|
|
|
|
|
|
|
self.results['virtualnetworks'] = self.curated(results)
|
|
|
|
|
|
|
|
|
|
|
|
return self.results
|
|
|
|
return self.results
|
|
|
|
|
|
|
|
|
|
|
@ -142,8 +221,7 @@ class AzureRMNetworkInterfaceFacts(AzureRMModuleBase):
|
|
|
|
pass
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
if item and self.has_tags(item.tags, self.tags):
|
|
|
|
if item and self.has_tags(item.tags, self.tags):
|
|
|
|
results = [self.serialize_obj(item, AZURE_OBJECT_CLASS)]
|
|
|
|
results = [item]
|
|
|
|
|
|
|
|
|
|
|
|
return results
|
|
|
|
return results
|
|
|
|
|
|
|
|
|
|
|
|
def list_resource_group(self):
|
|
|
|
def list_resource_group(self):
|
|
|
@ -156,7 +234,7 @@ class AzureRMNetworkInterfaceFacts(AzureRMModuleBase):
|
|
|
|
results = []
|
|
|
|
results = []
|
|
|
|
for item in response:
|
|
|
|
for item in response:
|
|
|
|
if self.has_tags(item.tags, self.tags):
|
|
|
|
if self.has_tags(item.tags, self.tags):
|
|
|
|
results.append(self.serialize_obj(item, AZURE_OBJECT_CLASS))
|
|
|
|
results.append(item)
|
|
|
|
return results
|
|
|
|
return results
|
|
|
|
|
|
|
|
|
|
|
|
def list_items(self):
|
|
|
|
def list_items(self):
|
|
|
@ -169,9 +247,50 @@ class AzureRMNetworkInterfaceFacts(AzureRMModuleBase):
|
|
|
|
results = []
|
|
|
|
results = []
|
|
|
|
for item in response:
|
|
|
|
for item in response:
|
|
|
|
if self.has_tags(item.tags, self.tags):
|
|
|
|
if self.has_tags(item.tags, self.tags):
|
|
|
|
results.append(self.serialize_obj(item, AZURE_OBJECT_CLASS))
|
|
|
|
results.append(item)
|
|
|
|
return results
|
|
|
|
return results
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def serialize(self, raws):
|
|
|
|
|
|
|
|
self.log("Serialize all items")
|
|
|
|
|
|
|
|
return [self.serialize_obj(item, AZURE_OBJECT_CLASS) for item in raws] if raws else []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def curated(self, raws):
|
|
|
|
|
|
|
|
self.log("Format all items")
|
|
|
|
|
|
|
|
return [self.virtualnetwork_to_dict(x) for x in raws] if raws else []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def virtualnetwork_to_dict(self, vnet):
|
|
|
|
|
|
|
|
results = dict(
|
|
|
|
|
|
|
|
id=vnet.id,
|
|
|
|
|
|
|
|
name=vnet.name,
|
|
|
|
|
|
|
|
location=vnet.location,
|
|
|
|
|
|
|
|
tags=vnet.tags,
|
|
|
|
|
|
|
|
provisioning_state=vnet.provisioning_state
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
if vnet.dhcp_options and len(vnet.dhcp_options.dns_servers) > 0:
|
|
|
|
|
|
|
|
results['dns_servers'] = []
|
|
|
|
|
|
|
|
for server in vnet.dhcp_options.dns_servers:
|
|
|
|
|
|
|
|
results['dns_servers'].append(server)
|
|
|
|
|
|
|
|
if vnet.address_space and len(vnet.address_space.address_prefixes) > 0:
|
|
|
|
|
|
|
|
results['address_prefixes'] = []
|
|
|
|
|
|
|
|
for space in vnet.address_space.address_prefixes:
|
|
|
|
|
|
|
|
results['address_prefixes'].append(space)
|
|
|
|
|
|
|
|
if vnet.subnets and len(vnet.subnets) > 0:
|
|
|
|
|
|
|
|
results['subnets'] = [self.subnet_to_dict(x) for x in vnet.subnets]
|
|
|
|
|
|
|
|
return results
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def subnet_to_dict(self, subnet):
|
|
|
|
|
|
|
|
result = dict(
|
|
|
|
|
|
|
|
id=subnet.id,
|
|
|
|
|
|
|
|
name=subnet.name,
|
|
|
|
|
|
|
|
provisioning_state=subnet.provisioning_state,
|
|
|
|
|
|
|
|
address_prefix=subnet.address_prefix,
|
|
|
|
|
|
|
|
network_security_group=subnet.network_security_group.id if subnet.network_security_group else None,
|
|
|
|
|
|
|
|
route_table=subnet.route_table.id if subnet.route_table else None
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
if subnet.service_endpoints:
|
|
|
|
|
|
|
|
result['service_endpoints'] = [{'service': item.service, 'locations': item.locations} for item in subnet.service_endpoints]
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
def main():
|
|
|
|
AzureRMNetworkInterfaceFacts()
|
|
|
|
AzureRMNetworkInterfaceFacts()
|
|
|
|