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
(cherry picked from commit c0000bc722)
pull/30252/head
Raja Venkataraman 7 years ago committed by Toshio Kuratomi
parent 77d1935f61
commit c92f44a806

@ -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)

Loading…
Cancel
Save