mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
cleaning up azure_rm_deployment samples & return value doc (#53436)
This commit is contained in:
parent
b6e669f135
commit
642f75990b
1 changed files with 147 additions and 115 deletions
|
@ -26,12 +26,19 @@ description:
|
||||||
For more information on Azure Resource Manager templates see https://azure.microsoft.com/en-us/documentation/articles/resource-group-template-deploy/."
|
For more information on Azure Resource Manager templates see https://azure.microsoft.com/en-us/documentation/articles/resource-group-template-deploy/."
|
||||||
|
|
||||||
options:
|
options:
|
||||||
resource_group_name:
|
resource_group:
|
||||||
description:
|
description:
|
||||||
- The resource group name to use or create to host the deployed template
|
- The resource group name to use or create to host the deployed template
|
||||||
required: true
|
required: true
|
||||||
aliases:
|
aliases:
|
||||||
- resource_group
|
- resource_group_name
|
||||||
|
name:
|
||||||
|
description:
|
||||||
|
- The name of the deployment to be tracked in the resource group deployment history. Re-using a deployment name
|
||||||
|
will overwrite the previous value in the resource group's deployment history.
|
||||||
|
default: ansible-arm
|
||||||
|
aliases:
|
||||||
|
- deployment_name
|
||||||
location:
|
location:
|
||||||
description:
|
description:
|
||||||
- The geo-locations in which the resource group will be located.
|
- The geo-locations in which the resource group will be located.
|
||||||
|
@ -44,14 +51,6 @@ options:
|
||||||
choices:
|
choices:
|
||||||
- complete
|
- complete
|
||||||
- incremental
|
- incremental
|
||||||
state:
|
|
||||||
description:
|
|
||||||
- If state is "present", template will be created. If state is "present" and if deployment exists, it will be
|
|
||||||
updated. If state is "absent", stack will be removed.
|
|
||||||
default: present
|
|
||||||
choices:
|
|
||||||
- present
|
|
||||||
- absent
|
|
||||||
template:
|
template:
|
||||||
description:
|
description:
|
||||||
- A hash containing the templates inline. This parameter is mutually exclusive with 'template_link'.
|
- A hash containing the templates inline. This parameter is mutually exclusive with 'template_link'.
|
||||||
|
@ -70,11 +69,6 @@ options:
|
||||||
description:
|
description:
|
||||||
- Uri of file containing the parameters body. This parameter is mutually exclusive with 'parameters'. Either
|
- Uri of file containing the parameters body. This parameter is mutually exclusive with 'parameters'. Either
|
||||||
one of them is required if "state" parameter is "present".
|
one of them is required if "state" parameter is "present".
|
||||||
deployment_name:
|
|
||||||
description:
|
|
||||||
- The name of the deployment to be tracked in the resource group deployment history. Re-using a deployment name
|
|
||||||
will overwrite the previous value in the resource group's deployment history.
|
|
||||||
default: ansible-arm
|
|
||||||
wait_for_deployment_completion:
|
wait_for_deployment_completion:
|
||||||
description:
|
description:
|
||||||
- Whether or not to block until the deployment has completed.
|
- Whether or not to block until the deployment has completed.
|
||||||
|
@ -84,6 +78,14 @@ options:
|
||||||
description:
|
description:
|
||||||
- Time (in seconds) to wait between polls when waiting for deployment completion.
|
- Time (in seconds) to wait between polls when waiting for deployment completion.
|
||||||
default: 10
|
default: 10
|
||||||
|
state:
|
||||||
|
description:
|
||||||
|
- If state is C(present), template will be created. If state is C(present) and deployment exists, it will be
|
||||||
|
updated. If state is C(absent), stack will be removed.
|
||||||
|
default: present
|
||||||
|
choices:
|
||||||
|
- present
|
||||||
|
- absent
|
||||||
|
|
||||||
extends_documentation_fragment:
|
extends_documentation_fragment:
|
||||||
- azure
|
- azure
|
||||||
|
@ -100,14 +102,15 @@ EXAMPLES = '''
|
||||||
# Destroy a template deployment
|
# Destroy a template deployment
|
||||||
- name: Destroy Azure Deploy
|
- name: Destroy Azure Deploy
|
||||||
azure_rm_deployment:
|
azure_rm_deployment:
|
||||||
|
resource_group: myResourceGroup
|
||||||
|
name: myDeployment
|
||||||
state: absent
|
state: absent
|
||||||
subscription_id: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
|
|
||||||
resource_group_name: dev-ops-cle
|
|
||||||
|
|
||||||
# Create or update a template deployment based on uris using parameter and template links
|
# Create or update a template deployment based on uris using parameter and template links
|
||||||
- name: Create Azure Deploy
|
- name: Create Azure Deploy
|
||||||
azure_rm_deployment:
|
azure_rm_deployment:
|
||||||
resource_group_name: dev-ops-cle
|
resource_group: myResourceGroup
|
||||||
|
name: myDeployment
|
||||||
template_link: 'https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/101-vm-simple-linux/azuredeploy.json'
|
template_link: 'https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/101-vm-simple-linux/azuredeploy.json'
|
||||||
parameters_link: 'https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/101-vm-simple-linux/azuredeploy.parameters.json'
|
parameters_link: 'https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/101-vm-simple-linux/azuredeploy.parameters.json'
|
||||||
|
|
||||||
|
@ -115,60 +118,38 @@ EXAMPLES = '''
|
||||||
# This deploys a VM with SSH support for a given public key, then stores the result in 'azure_vms'. The result is then
|
# This deploys a VM with SSH support for a given public key, then stores the result in 'azure_vms'. The result is then
|
||||||
# used to create a new host group. This host group is then used to wait for each instance to respond to the public IP SSH.
|
# used to create a new host group. This host group is then used to wait for each instance to respond to the public IP SSH.
|
||||||
---
|
---
|
||||||
- hosts: localhost
|
- name: Create Azure Deploy
|
||||||
connection: local
|
azure_rm_deployment:
|
||||||
gather_facts: no
|
resource_group: myResourceGroup
|
||||||
tasks:
|
name: myDeployment
|
||||||
- name: Destroy Azure Deploy
|
parameters:
|
||||||
azure_rm_deployment:
|
newStorageAccountName:
|
||||||
state: absent
|
value: devopsclestorage1
|
||||||
subscription_id: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
|
adminUsername:
|
||||||
resource_group_name: dev-ops-cle
|
value: devopscle
|
||||||
|
dnsNameForPublicIP:
|
||||||
- name: Create Azure Deploy
|
value: devopscleazure
|
||||||
azure_rm_deployment:
|
location:
|
||||||
subscription_id: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
|
value: West US
|
||||||
resource_group_name: dev-ops-cle
|
vmSize:
|
||||||
parameters:
|
value: Standard_A2
|
||||||
newStorageAccountName:
|
vmName:
|
||||||
value: devopsclestorage1
|
value: ansibleSshVm
|
||||||
adminUsername:
|
sshKeyData:
|
||||||
value: devopscle
|
value: YOUR_SSH_PUBLIC_KEY
|
||||||
dnsNameForPublicIP:
|
template_link: 'https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/101-vm-sshkey/azuredeploy.json'
|
||||||
value: devopscleazure
|
register: azure
|
||||||
location:
|
- name: Add new instance to host group
|
||||||
value: West US
|
add_host:
|
||||||
vmSize:
|
hostname: "{{ item['ips'][0].public_ip }}"
|
||||||
value: Standard_A2
|
groupname: azure_vms
|
||||||
vmName:
|
loop: "{{ azure.deployment.instances }}"
|
||||||
value: ansibleSshVm
|
|
||||||
sshKeyData:
|
|
||||||
value: YOUR_SSH_PUBLIC_KEY
|
|
||||||
template_link: 'https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/101-vm-sshkey/azuredeploy.json'
|
|
||||||
register: azure
|
|
||||||
|
|
||||||
- name: Add new instance to host group
|
|
||||||
add_host:
|
|
||||||
hostname: "{{ item['ips'][0].public_ip }}"
|
|
||||||
groupname: azure_vms
|
|
||||||
loop: "{{ azure.deployment.instances }}"
|
|
||||||
|
|
||||||
- hosts: azure_vms
|
|
||||||
user: devopscle
|
|
||||||
tasks:
|
|
||||||
- name: Wait for SSH to come up
|
|
||||||
wait_for:
|
|
||||||
port: 22
|
|
||||||
timeout: 2000
|
|
||||||
state: started
|
|
||||||
- name: echo the hostname of the vm
|
|
||||||
shell: hostname
|
|
||||||
|
|
||||||
# Deploy an Azure WebApp running a hello world'ish node app
|
# Deploy an Azure WebApp running a hello world'ish node app
|
||||||
- name: Create Azure WebApp Deployment at http://devopscleweb.azurewebsites.net/hello.js
|
- name: Create Azure WebApp Deployment at http://devopscleweb.azurewebsites.net/hello.js
|
||||||
azure_rm_deployment:
|
azure_rm_deployment:
|
||||||
subscription_id: cbbdaed0-fea9-4693-bf0c-d446ac93c030
|
resource_group: myResourceGroup
|
||||||
resource_group_name: dev-ops-cle-webapp
|
name: myDeployment
|
||||||
parameters:
|
parameters:
|
||||||
repoURL:
|
repoURL:
|
||||||
value: 'https://github.com/devigned/az-roadshow-oss.git'
|
value: 'https://github.com/devigned/az-roadshow-oss.git'
|
||||||
|
@ -185,9 +166,8 @@ EXAMPLES = '''
|
||||||
# Create or update a template deployment based on an inline template and parameters
|
# Create or update a template deployment based on an inline template and parameters
|
||||||
- name: Create Azure Deploy
|
- name: Create Azure Deploy
|
||||||
azure_rm_deployment:
|
azure_rm_deployment:
|
||||||
subscription_id: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
|
resource_group: myResourceGroup
|
||||||
resource_group_name: dev-ops-cle
|
name: myDeployment
|
||||||
|
|
||||||
template:
|
template:
|
||||||
$schema: "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#"
|
$schema: "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#"
|
||||||
contentVersion: "1.0.0.0"
|
contentVersion: "1.0.0.0"
|
||||||
|
@ -331,30 +311,82 @@ EXAMPLES = '''
|
||||||
|
|
||||||
RETURN = '''
|
RETURN = '''
|
||||||
deployment:
|
deployment:
|
||||||
description: Deployment details
|
description: Deployment details
|
||||||
type: dict
|
type: complex
|
||||||
returned: always
|
returned: always
|
||||||
sample:
|
contains:
|
||||||
group_name:
|
group_name:
|
||||||
description: Name of the resource group
|
description: Name of the resource group
|
||||||
type: str
|
type: str
|
||||||
returned: always
|
returned: always
|
||||||
id:
|
sample: myResourceGroup
|
||||||
description: The Azure ID of the deployment
|
id:
|
||||||
type: str
|
description: The Azure ID of the deployment
|
||||||
returned: always
|
type: str
|
||||||
instances:
|
returned: always
|
||||||
description: Provides the public IP addresses for each VM instance.
|
sample: "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myResourceGroup/providers/Microsoft.Resources/deployments/myD
|
||||||
type: list
|
eployment"
|
||||||
returned: always
|
instances:
|
||||||
name:
|
description: Provides the public IP addresses for each VM instance.
|
||||||
description: Name of the deployment
|
type: list
|
||||||
type: str
|
returned: always
|
||||||
returned: always
|
contains:
|
||||||
outputs:
|
ips:
|
||||||
description: Dictionary of outputs received from the deployment
|
description: List of Public IP addresses.
|
||||||
type: dict
|
type: list
|
||||||
returned: always
|
returned: always
|
||||||
|
contains:
|
||||||
|
dns_settings:
|
||||||
|
description: DNS Settings
|
||||||
|
type: complex
|
||||||
|
returned: always
|
||||||
|
contains:
|
||||||
|
domain_name_label:
|
||||||
|
description: Domain Name Label
|
||||||
|
type: str
|
||||||
|
returned: always
|
||||||
|
sample: myvirtualmachine
|
||||||
|
fqdn:
|
||||||
|
description: Fully Qualified Domain Name.
|
||||||
|
type: str
|
||||||
|
returned: always
|
||||||
|
sample: myvirtualmachine.eastus2.cloudapp.azure.com
|
||||||
|
id:
|
||||||
|
description: Public IP resource id.
|
||||||
|
returned: always
|
||||||
|
type: str
|
||||||
|
sample: "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myResourceGroup/providers/Microsoft.Network/p
|
||||||
|
ublicIPAddresses/myPublicIP"
|
||||||
|
name:
|
||||||
|
decription: Public IP resource name.
|
||||||
|
returned: always
|
||||||
|
type: str
|
||||||
|
sample: myPublicIP
|
||||||
|
public_ip:
|
||||||
|
description: Public IP address value.
|
||||||
|
returned: always
|
||||||
|
type: str
|
||||||
|
sample: 104.209.244.123
|
||||||
|
public_ip_allocation_method:
|
||||||
|
description: Public IP allocation method.
|
||||||
|
returned: always
|
||||||
|
type: str
|
||||||
|
sample: Dynamic
|
||||||
|
vm_name:
|
||||||
|
description: Virtual machine name.
|
||||||
|
returned: always
|
||||||
|
type: str
|
||||||
|
sample: myvirtualmachine
|
||||||
|
name:
|
||||||
|
description: Name of the deployment
|
||||||
|
type: str
|
||||||
|
returned: always
|
||||||
|
sample: myDeployment
|
||||||
|
outputs:
|
||||||
|
description: Dictionary of outputs received from the deployment.
|
||||||
|
type: complex
|
||||||
|
returned: always
|
||||||
|
sample: { "hostname": { "type": "String", "value": "myvirtualmachine.eastus2.cloudapp.azure.com" } }
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
@ -384,7 +416,8 @@ class AzureRMDeploymentManager(AzureRMModuleBase):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
||||||
self.module_arg_spec = dict(
|
self.module_arg_spec = dict(
|
||||||
resource_group_name=dict(type='str', required=True, aliases=['resource_group']),
|
resource_group=dict(type='str', required=True, aliases=['resource_group_name']),
|
||||||
|
name=dict(type='str', default="ansible-arm", aliases=['deployment_name']),
|
||||||
state=dict(type='str', default='present', choices=['present', 'absent']),
|
state=dict(type='str', default='present', choices=['present', 'absent']),
|
||||||
template=dict(type='dict', default=None),
|
template=dict(type='dict', default=None),
|
||||||
parameters=dict(type='dict', default=None),
|
parameters=dict(type='dict', default=None),
|
||||||
|
@ -392,7 +425,6 @@ class AzureRMDeploymentManager(AzureRMModuleBase):
|
||||||
parameters_link=dict(type='str', default=None),
|
parameters_link=dict(type='str', default=None),
|
||||||
location=dict(type='str', default="westus"),
|
location=dict(type='str', default="westus"),
|
||||||
deployment_mode=dict(type='str', default='incremental', choices=['complete', 'incremental']),
|
deployment_mode=dict(type='str', default='incremental', choices=['complete', 'incremental']),
|
||||||
deployment_name=dict(type='str', default="ansible-arm"),
|
|
||||||
wait_for_deployment_completion=dict(type='bool', default=True),
|
wait_for_deployment_completion=dict(type='bool', default=True),
|
||||||
wait_for_deployment_polling_period=dict(type='int', default=10)
|
wait_for_deployment_polling_period=dict(type='int', default=10)
|
||||||
)
|
)
|
||||||
|
@ -400,7 +432,7 @@ class AzureRMDeploymentManager(AzureRMModuleBase):
|
||||||
mutually_exclusive = [('template', 'template_link'),
|
mutually_exclusive = [('template', 'template_link'),
|
||||||
('parameters', 'parameters_link')]
|
('parameters', 'parameters_link')]
|
||||||
|
|
||||||
self.resource_group_name = None
|
self.resource_group = None
|
||||||
self.state = None
|
self.state = None
|
||||||
self.template = None
|
self.template = None
|
||||||
self.parameters = None
|
self.parameters = None
|
||||||
|
@ -408,7 +440,7 @@ class AzureRMDeploymentManager(AzureRMModuleBase):
|
||||||
self.parameters_link = None
|
self.parameters_link = None
|
||||||
self.location = None
|
self.location = None
|
||||||
self.deployment_mode = None
|
self.deployment_mode = None
|
||||||
self.deployment_name = None
|
self.name = None
|
||||||
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
|
||||||
|
@ -433,8 +465,8 @@ class AzureRMDeploymentManager(AzureRMModuleBase):
|
||||||
deployment = self.deploy_template()
|
deployment = self.deploy_template()
|
||||||
if deployment is None:
|
if deployment is None:
|
||||||
self.results['deployment'] = dict(
|
self.results['deployment'] = dict(
|
||||||
name=self.deployment_name,
|
name=self.name,
|
||||||
group_name=self.resource_group_name,
|
group_name=self.resource_group,
|
||||||
id=None,
|
id=None,
|
||||||
outputs=None,
|
outputs=None,
|
||||||
instances=None
|
instances=None
|
||||||
|
@ -442,7 +474,7 @@ class AzureRMDeploymentManager(AzureRMModuleBase):
|
||||||
else:
|
else:
|
||||||
self.results['deployment'] = dict(
|
self.results['deployment'] = dict(
|
||||||
name=deployment.name,
|
name=deployment.name,
|
||||||
group_name=self.resource_group_name,
|
group_name=self.resource_group,
|
||||||
id=deployment.id,
|
id=deployment.id,
|
||||||
outputs=deployment.properties.outputs,
|
outputs=deployment.properties.outputs,
|
||||||
instances=self._get_instances(deployment)
|
instances=self._get_instances(deployment)
|
||||||
|
@ -452,7 +484,7 @@ class AzureRMDeploymentManager(AzureRMModuleBase):
|
||||||
self.results['msg'] = 'deployment succeeded'
|
self.results['msg'] = 'deployment succeeded'
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
if self.get_resource_group(self.resource_group_name):
|
if self.get_resource_group(self.resource_group):
|
||||||
self.destroy_resource_group()
|
self.destroy_resource_group()
|
||||||
self.results['changed'] = True
|
self.results['changed'] = True
|
||||||
self.results['msg'] = "deployment deleted"
|
self.results['msg'] = "deployment deleted"
|
||||||
|
@ -488,7 +520,7 @@ class AzureRMDeploymentManager(AzureRMModuleBase):
|
||||||
if self.append_tags and self.tags:
|
if self.append_tags and self.tags:
|
||||||
try:
|
try:
|
||||||
# fetch the RG directly (instead of using the base helper) since we don't want to exit if it's missing
|
# fetch the RG directly (instead of using the base helper) since we don't want to exit if it's missing
|
||||||
rg = self.rm_client.resource_groups.get(self.resource_group_name)
|
rg = self.rm_client.resource_groups.get(self.resource_group)
|
||||||
if rg.tags:
|
if rg.tags:
|
||||||
self.tags = dict(self.tags, **rg.tags)
|
self.tags = dict(self.tags, **rg.tags)
|
||||||
except CloudError:
|
except CloudError:
|
||||||
|
@ -498,13 +530,13 @@ class AzureRMDeploymentManager(AzureRMModuleBase):
|
||||||
params = self.rm_models.ResourceGroup(location=self.location, tags=self.tags)
|
params = self.rm_models.ResourceGroup(location=self.location, tags=self.tags)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.rm_client.resource_groups.create_or_update(self.resource_group_name, params)
|
self.rm_client.resource_groups.create_or_update(self.resource_group, params)
|
||||||
except CloudError as exc:
|
except CloudError as exc:
|
||||||
self.fail("Resource group create_or_update failed with status code: %s and message: %s" %
|
self.fail("Resource group create_or_update failed with status code: %s and message: %s" %
|
||||||
(exc.status_code, exc.message))
|
(exc.status_code, exc.message))
|
||||||
try:
|
try:
|
||||||
result = self.rm_client.deployments.create_or_update(self.resource_group_name,
|
result = self.rm_client.deployments.create_or_update(self.resource_group,
|
||||||
self.deployment_name,
|
self.name,
|
||||||
deploy_parameter)
|
deploy_parameter)
|
||||||
|
|
||||||
deployment_result = None
|
deployment_result = None
|
||||||
|
@ -513,16 +545,16 @@ class AzureRMDeploymentManager(AzureRMModuleBase):
|
||||||
while deployment_result.properties is None or deployment_result.properties.provisioning_state not in ['Canceled', 'Failed', 'Deleted',
|
while deployment_result.properties is None or deployment_result.properties.provisioning_state not in ['Canceled', 'Failed', 'Deleted',
|
||||||
'Succeeded']:
|
'Succeeded']:
|
||||||
time.sleep(self.wait_for_deployment_polling_period)
|
time.sleep(self.wait_for_deployment_polling_period)
|
||||||
deployment_result = self.rm_client.deployments.get(self.resource_group_name, self.deployment_name)
|
deployment_result = self.rm_client.deployments.get(self.resource_group, self.name)
|
||||||
except CloudError as exc:
|
except CloudError as exc:
|
||||||
failed_deployment_operations = self._get_failed_deployment_operations(self.deployment_name)
|
failed_deployment_operations = self._get_failed_deployment_operations(self.name)
|
||||||
self.log("Deployment failed %s: %s" % (exc.status_code, exc.message))
|
self.log("Deployment failed %s: %s" % (exc.status_code, exc.message))
|
||||||
self.fail("Deployment failed with status code: %s and message: %s" % (exc.status_code, exc.message),
|
self.fail("Deployment failed with status code: %s and message: %s" % (exc.status_code, exc.message),
|
||||||
failed_deployment_operations=failed_deployment_operations)
|
failed_deployment_operations=failed_deployment_operations)
|
||||||
|
|
||||||
if self.wait_for_deployment_completion and deployment_result.properties.provisioning_state != 'Succeeded':
|
if self.wait_for_deployment_completion and deployment_result.properties.provisioning_state != 'Succeeded':
|
||||||
self.log("provisioning state: %s" % deployment_result.properties.provisioning_state)
|
self.log("provisioning state: %s" % deployment_result.properties.provisioning_state)
|
||||||
failed_deployment_operations = self._get_failed_deployment_operations(self.deployment_name)
|
failed_deployment_operations = self._get_failed_deployment_operations(self.name)
|
||||||
self.fail('Deployment failed. Deployment id: %s' % deployment_result.id,
|
self.fail('Deployment failed. Deployment id: %s' % deployment_result.id,
|
||||||
failed_deployment_operations=failed_deployment_operations)
|
failed_deployment_operations=failed_deployment_operations)
|
||||||
|
|
||||||
|
@ -533,7 +565,7 @@ class AzureRMDeploymentManager(AzureRMModuleBase):
|
||||||
Destroy the targeted resource group
|
Destroy the targeted resource group
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
result = self.rm_client.resource_groups.delete(self.resource_group_name)
|
result = self.rm_client.resource_groups.delete(self.resource_group)
|
||||||
result.wait() # Blocking wait till the delete is finished
|
result.wait() # Blocking wait till the delete is finished
|
||||||
except CloudError as e:
|
except CloudError as e:
|
||||||
if e.status_code == 404 or e.status_code == 204:
|
if e.status_code == 404 or e.status_code == 204:
|
||||||
|
@ -551,7 +583,7 @@ class AzureRMDeploymentManager(AzureRMModuleBase):
|
||||||
'Microsoft.Resources/deployments' in operation.properties.target_resource.id:
|
'Microsoft.Resources/deployments' in operation.properties.target_resource.id:
|
||||||
nested_deployment = operation.properties.target_resource.resource_name
|
nested_deployment = operation.properties.target_resource.resource_name
|
||||||
try:
|
try:
|
||||||
nested_operations = self.rm_client.deployment_operations.list(self.resource_group_name,
|
nested_operations = self.rm_client.deployment_operations.list(self.resource_group,
|
||||||
nested_deployment)
|
nested_deployment)
|
||||||
except CloudError as exc:
|
except CloudError as exc:
|
||||||
self.fail("List nested deployment operations failed with status code: %s and message: %s" %
|
self.fail("List nested deployment operations failed with status code: %s and message: %s" %
|
||||||
|
@ -560,13 +592,13 @@ class AzureRMDeploymentManager(AzureRMModuleBase):
|
||||||
new_operations += new_nested_operations
|
new_operations += new_nested_operations
|
||||||
return new_operations
|
return new_operations
|
||||||
|
|
||||||
def _get_failed_deployment_operations(self, deployment_name):
|
def _get_failed_deployment_operations(self, name):
|
||||||
results = []
|
results = []
|
||||||
# time.sleep(15) # there is a race condition between when we ask for deployment status and when the
|
# time.sleep(15) # there is a race condition between when we ask for deployment status and when the
|
||||||
# # status is available.
|
# # status is available.
|
||||||
|
|
||||||
try:
|
try:
|
||||||
operations = self.rm_client.deployment_operations.list(self.resource_group_name, deployment_name)
|
operations = self.rm_client.deployment_operations.list(self.resource_group, name)
|
||||||
except CloudError as exc:
|
except CloudError as exc:
|
||||||
self.fail("Get deployment failed with status code: %s and message: %s" %
|
self.fail("Get deployment failed with status code: %s and message: %s" %
|
||||||
(exc.status_code, exc.message))
|
(exc.status_code, exc.message))
|
||||||
|
@ -641,7 +673,7 @@ class AzureRMDeploymentManager(AzureRMModuleBase):
|
||||||
|
|
||||||
def _nic_to_public_ips_instance(self, nics):
|
def _nic_to_public_ips_instance(self, nics):
|
||||||
return [self.network_client.public_ip_addresses.get(public_ip_id.split('/')[4], public_ip_id.split('/')[-1])
|
return [self.network_client.public_ip_addresses.get(public_ip_id.split('/')[4], public_ip_id.split('/')[-1])
|
||||||
for nic_obj in (self.network_client.network_interfaces.get(self.resource_group_name,
|
for nic_obj in (self.network_client.network_interfaces.get(self.resource_group,
|
||||||
nic['dep'].resource_name) for nic in nics)
|
nic['dep'].resource_name) for nic in nics)
|
||||||
for public_ip_id in [ip_conf_instance.public_ip_address.id
|
for public_ip_id in [ip_conf_instance.public_ip_address.id
|
||||||
for ip_conf_instance in nic_obj.ip_configurations
|
for ip_conf_instance in nic_obj.ip_configurations
|
||||||
|
|
Loading…
Reference in a new issue