mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02: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:
|
||||
description:
|
||||
- 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:
|
||||
- azure
|
||||
|
@ -182,7 +191,8 @@ def managed_disk_to_dict(managed_disk):
|
|||
disk_size_gb=managed_disk.disk_size_gb,
|
||||
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,
|
||||
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(
|
||||
type='str'
|
||||
),
|
||||
zone=dict(
|
||||
type='str',
|
||||
choices=['', '1', '2', '3']
|
||||
)
|
||||
)
|
||||
required_if = [
|
||||
|
@ -248,6 +262,7 @@ class AzureRMManagedDisk(AzureRMModuleBase):
|
|||
self.os_type = None
|
||||
self.disk_size_gb = None
|
||||
self.tags = None
|
||||
self.zone = None
|
||||
self.managed_by = None
|
||||
super(AzureRMManagedDisk, self).__init__(
|
||||
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)))
|
||||
|
||||
def generate_managed_disk_property(self):
|
||||
# TODO: Add support for EncryptionSettings, DiskIOPSReadWrite, DiskMBpsReadWrite, Zones
|
||||
# TODO: Add support for EncryptionSettings, DiskIOPSReadWrite, DiskMBpsReadWrite
|
||||
disk_params = {}
|
||||
creation_data = {}
|
||||
disk_params['location'] = self.location
|
||||
disk_params['tags'] = self.tags
|
||||
if self.zone:
|
||||
disk_params['zones'] = [self.zone]
|
||||
if self.storage_account_type:
|
||||
storage_account_type = self.compute_models.DiskSku(name=self.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 not found_disk['tags'] == new_disk['tags']:
|
||||
resp = True
|
||||
if self.zone is not None:
|
||||
if not found_disk['zone'] == self.zone:
|
||||
resp = True
|
||||
return resp
|
||||
|
||||
def delete_managed_disk(self):
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
state: absent
|
||||
with_items:
|
||||
- "md{{ rpfx }}os"
|
||||
- "md{{ rpfx }}3"
|
||||
- "md{{ rpfx }}2"
|
||||
- "md{{ rpfx }}1"
|
||||
|
||||
|
@ -64,6 +65,24 @@
|
|||
- output.state.os_type == None
|
||||
- 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
|
||||
azure_rm_managed_disk:
|
||||
resource_group: "{{ resource_group }}"
|
||||
|
@ -487,6 +506,7 @@
|
|||
with_items:
|
||||
- 1
|
||||
- 2
|
||||
- 3
|
||||
|
||||
- name: Delete virtual machine
|
||||
azure_rm_virtualmachine:
|
||||
|
|
Loading…
Reference in a new issue