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

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
This commit is contained in:
Raja Venkataraman 2017-09-12 22:37:32 +05:30 committed by Matt Davis
parent a2b3bb1e49
commit c0000bc722

View file

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