From c0000bc722e7f58b1dddd2361156293b124ad379 Mon Sep 17 00:00:00 2001 From: Raja Venkataraman Date: Tue, 12 Sep 2017 22:37:32 +0530 Subject: [PATCH] Handle wait_for_deployment_completion during Azure deployment. (#26079) Pull the get_poller_result inside the if block so that if the caller has wait_for_deployment_completion=False, it doesnt block and wait for it to finish. Also, since the result contains information about the deployment, provide None values for it in the output.(Not sure if this needs to be documented) Fixes #26014 --- .../cloud/azure/azure_rm_deployment.py | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/lib/ansible/modules/cloud/azure/azure_rm_deployment.py b/lib/ansible/modules/cloud/azure/azure_rm_deployment.py index f6f2c698db..00d8e0a97d 100644 --- a/lib/ansible/modules/cloud/azure/azure_rm_deployment.py +++ b/lib/ansible/modules/cloud/azure/azure_rm_deployment.py @@ -446,13 +446,23 @@ class AzureRMDeploymentManager(AzureRMModuleBase): if self.state == 'present': deployment = self.deploy_template() - self.results['deployment'] = dict( - name=deployment.name, - group_name=self.resource_group_name, - id=deployment.id, - outputs=deployment.properties.outputs, - instances=self._get_instances(deployment) - ) + if deployment is None: + self.results['deployment'] = dict( + name=self.deployment_name, + group_name=self.resource_group_name, + id=None, + outputs=None, + instances=None + ) + else: + self.results['deployment'] = dict( + name=deployment.name, + group_name=self.resource_group_name, + id=deployment.id, + outputs=deployment.properties.outputs, + instances=self._get_instances(deployment) + ) + self.results['changed'] = True self.results['msg'] = 'deployment succeeded' else: @@ -498,8 +508,9 @@ class AzureRMDeploymentManager(AzureRMModuleBase): self.deployment_name, deploy_parameter) - deployment_result = self.get_poller_result(result) + deployment_result = None if self.wait_for_deployment_completion: + deployment_result = self.get_poller_result(result) while deployment_result.properties is None or deployment_result.properties.provisioning_state not in ['Canceled', 'Failed', 'Deleted', 'Succeeded']: time.sleep(self.wait_for_deployment_polling_period)