|
|
@ -416,6 +416,7 @@ class AzureRMDeploymentManager(AzureRMModuleBase):
|
|
|
|
self.wait_for_deployment_completion = None
|
|
|
|
self.wait_for_deployment_completion = None
|
|
|
|
self.wait_for_deployment_polling_period = None
|
|
|
|
self.wait_for_deployment_polling_period = None
|
|
|
|
self.tags = None
|
|
|
|
self.tags = None
|
|
|
|
|
|
|
|
self.append_tags = None
|
|
|
|
|
|
|
|
|
|
|
|
self.results = dict(
|
|
|
|
self.results = dict(
|
|
|
|
deployment=dict(),
|
|
|
|
deployment=dict(),
|
|
|
@ -429,7 +430,7 @@ class AzureRMDeploymentManager(AzureRMModuleBase):
|
|
|
|
|
|
|
|
|
|
|
|
def exec_module(self, **kwargs):
|
|
|
|
def exec_module(self, **kwargs):
|
|
|
|
|
|
|
|
|
|
|
|
for key in list(self.module_arg_spec.keys()) + ['tags']:
|
|
|
|
for key in list(self.module_arg_spec.keys()) + ['append_tags', 'tags']:
|
|
|
|
setattr(self, key, kwargs[key])
|
|
|
|
setattr(self, key, kwargs[key])
|
|
|
|
|
|
|
|
|
|
|
|
if self.state == 'present':
|
|
|
|
if self.state == 'present':
|
|
|
@ -454,10 +455,14 @@ class AzureRMDeploymentManager(AzureRMModuleBase):
|
|
|
|
self.results['changed'] = True
|
|
|
|
self.results['changed'] = True
|
|
|
|
self.results['msg'] = 'deployment succeeded'
|
|
|
|
self.results['msg'] = 'deployment succeeded'
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
if self.resource_group_exists(self.resource_group_name):
|
|
|
|
try:
|
|
|
|
self.destroy_resource_group()
|
|
|
|
if self.get_resource_group(self.resource_group_name):
|
|
|
|
self.results['changed'] = True
|
|
|
|
self.destroy_resource_group()
|
|
|
|
self.results['msg'] = "deployment deleted"
|
|
|
|
self.results['changed'] = True
|
|
|
|
|
|
|
|
self.results['msg'] = "deployment deleted"
|
|
|
|
|
|
|
|
except CloudError:
|
|
|
|
|
|
|
|
# resource group does not exist
|
|
|
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
return self.results
|
|
|
|
return self.results
|
|
|
|
|
|
|
|
|
|
|
@ -484,6 +489,15 @@ class AzureRMDeploymentManager(AzureRMModuleBase):
|
|
|
|
uri=self.template_link
|
|
|
|
uri=self.template_link
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if self.append_tags and self.tags:
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
rg = self.get_resource_group(self.resource_group_name)
|
|
|
|
|
|
|
|
if rg.tags:
|
|
|
|
|
|
|
|
self.tags = dict(self.tags, **rg.tags)
|
|
|
|
|
|
|
|
except CloudError:
|
|
|
|
|
|
|
|
# resource group does not exist
|
|
|
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
params = self.rm_models.ResourceGroup(location=self.location, tags=self.tags)
|
|
|
|
params = self.rm_models.ResourceGroup(location=self.location, tags=self.tags)
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
@ -531,19 +545,6 @@ class AzureRMDeploymentManager(AzureRMModuleBase):
|
|
|
|
self.fail("Delete resource group and deploy failed with status code: %s and message: %s" %
|
|
|
|
self.fail("Delete resource group and deploy failed with status code: %s and message: %s" %
|
|
|
|
(e.status_code, e.message))
|
|
|
|
(e.status_code, e.message))
|
|
|
|
|
|
|
|
|
|
|
|
def resource_group_exists(self, resource_group):
|
|
|
|
|
|
|
|
'''
|
|
|
|
|
|
|
|
Return True/False based on existence of requested resource group.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
:param resource_group: string. Name of a resource group.
|
|
|
|
|
|
|
|
:return: boolean
|
|
|
|
|
|
|
|
'''
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
self.rm_client.resource_groups.get(resource_group)
|
|
|
|
|
|
|
|
except CloudError:
|
|
|
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _get_failed_nested_operations(self, current_operations):
|
|
|
|
def _get_failed_nested_operations(self, current_operations):
|
|
|
|
new_operations = []
|
|
|
|
new_operations = []
|
|
|
|
for operation in current_operations:
|
|
|
|
for operation in current_operations:
|
|
|
|