1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Add reference to VNET resource group (#34576)

Ported #26052
This commit is contained in:
radixdlt 2018-03-07 09:01:33 +00:00 committed by ansibot
parent b7bc61c7df
commit c6a6ea5d98

View file

@ -156,6 +156,11 @@ options:
- ReadWrite
default: ReadOnly
version_added: "2.4"
virtual_network_resource_group:
description:
- When creating a virtual machine, if a specific virtual network from another resource group should be
used, use this parameter to specify the resource group to use.
version_added: "2.5"
virtual_network_name:
description:
- Virtual Network name.
@ -378,6 +383,7 @@ class AzureRMVirtualMachineScaleSet(AzureRMModuleBase):
data_disks=dict(type='list'),
subnet_name=dict(type='str', aliases=['subnet']),
load_balancer=dict(type='str'),
virtual_network_resource_group=dict(type='str'),
virtual_network_name=dict(type='str', aliases=['virtual_network']),
remove_on_absent=dict(type='list', default=['all']),
)
@ -401,6 +407,7 @@ class AzureRMVirtualMachineScaleSet(AzureRMModuleBase):
self.data_disks = None
self.os_type = None
self.subnet_name = None
self.virtual_network_resource_group = None
self.virtual_network_name = None
self.tags = None
self.differences = None
@ -425,6 +432,10 @@ class AzureRMVirtualMachineScaleSet(AzureRMModuleBase):
# make sure options are lower case
self.remove_on_absent = set([resource.lower() for resource in self.remove_on_absent])
# default virtual_network_resource_group to resource_group
if not self.virtual_network_resource_group:
self.virtual_network_resource_group = self.resource_group
changed = False
results = dict()
vmss = None
@ -721,7 +732,7 @@ class AzureRMVirtualMachineScaleSet(AzureRMModuleBase):
def get_virtual_network(self, name):
try:
vnet = self.network_client.virtual_networks.get(self.resource_group, name)
vnet = self.network_client.virtual_networks.get(self.virtual_network_resource_group, name)
return vnet
except CloudError as exc:
self.fail("Error fetching virtual network {0} - {1}".format(name, str(exc)))
@ -729,7 +740,7 @@ class AzureRMVirtualMachineScaleSet(AzureRMModuleBase):
def get_subnet(self, vnet_name, subnet_name):
self.log("Fetching subnet {0} in virtual network {1}".format(subnet_name, vnet_name))
try:
subnet = self.network_client.subnets.get(self.resource_group, vnet_name, subnet_name)
subnet = self.network_client.subnets.get(self.virtual_network_resource_group, vnet_name, subnet_name)
except CloudError as exc:
self.fail("Error: fetching subnet {0} in virtual network {1} - {2}".format(
subnet_name,