mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-30 06:11:26 -07:00
Update azure_rm_managed_disk.py --add zones (#53788)
This commit is contained in:
parent
c8f2becb7a
commit
3694711a7e
2 changed files with 42 additions and 2 deletions
|
@ -93,6 +93,15 @@ options:
|
||||||
tags:
|
tags:
|
||||||
description:
|
description:
|
||||||
- Tags to assign to the managed disk.
|
- Tags to assign to the managed disk.
|
||||||
|
zone:
|
||||||
|
description:
|
||||||
|
- "Allowed values: 1, 2, 3, ''."
|
||||||
|
choices:
|
||||||
|
- 1
|
||||||
|
- 2
|
||||||
|
- 3
|
||||||
|
- ''
|
||||||
|
version_added: "2.8"
|
||||||
|
|
||||||
extends_documentation_fragment:
|
extends_documentation_fragment:
|
||||||
- azure
|
- azure
|
||||||
|
@ -182,7 +191,8 @@ def managed_disk_to_dict(managed_disk):
|
||||||
disk_size_gb=managed_disk.disk_size_gb,
|
disk_size_gb=managed_disk.disk_size_gb,
|
||||||
os_type=managed_disk.os_type.lower() if managed_disk.os_type else None,
|
os_type=managed_disk.os_type.lower() if managed_disk.os_type else None,
|
||||||
storage_account_type=managed_disk.sku.name if managed_disk.sku else None,
|
storage_account_type=managed_disk.sku.name if managed_disk.sku else None,
|
||||||
managed_by=managed_disk.managed_by
|
managed_by=managed_disk.managed_by,
|
||||||
|
zone=managed_disk.zones[0] if managed_disk.zones and len(managed_disk.zones) > 0 else ''
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -228,6 +238,10 @@ class AzureRMManagedDisk(AzureRMModuleBase):
|
||||||
),
|
),
|
||||||
managed_by=dict(
|
managed_by=dict(
|
||||||
type='str'
|
type='str'
|
||||||
|
),
|
||||||
|
zone=dict(
|
||||||
|
type='str',
|
||||||
|
choices=['', '1', '2', '3']
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
required_if = [
|
required_if = [
|
||||||
|
@ -248,6 +262,7 @@ class AzureRMManagedDisk(AzureRMModuleBase):
|
||||||
self.os_type = None
|
self.os_type = None
|
||||||
self.disk_size_gb = None
|
self.disk_size_gb = None
|
||||||
self.tags = None
|
self.tags = None
|
||||||
|
self.zone = None
|
||||||
self.managed_by = None
|
self.managed_by = None
|
||||||
super(AzureRMManagedDisk, self).__init__(
|
super(AzureRMManagedDisk, self).__init__(
|
||||||
derived_arg_spec=self.module_arg_spec,
|
derived_arg_spec=self.module_arg_spec,
|
||||||
|
@ -338,11 +353,13 @@ class AzureRMManagedDisk(AzureRMModuleBase):
|
||||||
self.fail("Error getting virtual machine {0} - {1}".format(name, str(exc)))
|
self.fail("Error getting virtual machine {0} - {1}".format(name, str(exc)))
|
||||||
|
|
||||||
def generate_managed_disk_property(self):
|
def generate_managed_disk_property(self):
|
||||||
# TODO: Add support for EncryptionSettings, DiskIOPSReadWrite, DiskMBpsReadWrite, Zones
|
# TODO: Add support for EncryptionSettings, DiskIOPSReadWrite, DiskMBpsReadWrite
|
||||||
disk_params = {}
|
disk_params = {}
|
||||||
creation_data = {}
|
creation_data = {}
|
||||||
disk_params['location'] = self.location
|
disk_params['location'] = self.location
|
||||||
disk_params['tags'] = self.tags
|
disk_params['tags'] = self.tags
|
||||||
|
if self.zone:
|
||||||
|
disk_params['zones'] = [self.zone]
|
||||||
if self.storage_account_type:
|
if self.storage_account_type:
|
||||||
storage_account_type = self.compute_models.DiskSku(name=self.storage_account_type)
|
storage_account_type = self.compute_models.DiskSku(name=self.storage_account_type)
|
||||||
disk_params['sku'] = storage_account_type
|
disk_params['sku'] = storage_account_type
|
||||||
|
@ -393,6 +410,9 @@ class AzureRMManagedDisk(AzureRMModuleBase):
|
||||||
if new_disk.get('tags') is not None:
|
if new_disk.get('tags') is not None:
|
||||||
if not found_disk['tags'] == new_disk['tags']:
|
if not found_disk['tags'] == new_disk['tags']:
|
||||||
resp = True
|
resp = True
|
||||||
|
if self.zone is not None:
|
||||||
|
if not found_disk['zone'] == self.zone:
|
||||||
|
resp = True
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
def delete_managed_disk(self):
|
def delete_managed_disk(self):
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
state: absent
|
state: absent
|
||||||
with_items:
|
with_items:
|
||||||
- "md{{ rpfx }}os"
|
- "md{{ rpfx }}os"
|
||||||
|
- "md{{ rpfx }}3"
|
||||||
- "md{{ rpfx }}2"
|
- "md{{ rpfx }}2"
|
||||||
- "md{{ rpfx }}1"
|
- "md{{ rpfx }}1"
|
||||||
|
|
||||||
|
@ -64,6 +65,24 @@
|
||||||
- output.state.os_type == None
|
- output.state.os_type == None
|
||||||
- output.state.storage_account_type == "Standard_LRS"
|
- output.state.storage_account_type == "Standard_LRS"
|
||||||
|
|
||||||
|
- name: Create new managed disk with zone
|
||||||
|
azure_rm_managed_disk:
|
||||||
|
resource_group: "{{ resource_group }}"
|
||||||
|
name: "md{{ rpfx }}3"
|
||||||
|
storage_account_type: "Standard_LRS"
|
||||||
|
disk_size_gb: 1
|
||||||
|
zone: 1
|
||||||
|
tags:
|
||||||
|
testing: testing
|
||||||
|
delete: never
|
||||||
|
register: output
|
||||||
|
|
||||||
|
- name: Assert status succeeded and results include an zone value
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- output.changed
|
||||||
|
- output.state.zone == ["1"]
|
||||||
|
|
||||||
- name: Change the operating system type of the managed disk to linux
|
- name: Change the operating system type of the managed disk to linux
|
||||||
azure_rm_managed_disk:
|
azure_rm_managed_disk:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
|
@ -487,6 +506,7 @@
|
||||||
with_items:
|
with_items:
|
||||||
- 1
|
- 1
|
||||||
- 2
|
- 2
|
||||||
|
- 3
|
||||||
|
|
||||||
- name: Delete virtual machine
|
- name: Delete virtual machine
|
||||||
azure_rm_virtualmachine:
|
azure_rm_virtualmachine:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue