From c8b2ddfc581d06c367306b6152da7bfca9b80df9 Mon Sep 17 00:00:00 2001 From: Maxence Date: Fri, 27 Aug 2021 21:18:01 +0000 Subject: [PATCH 1/3] Fix os_type comparison in azure_rm_manageddisk with existing disk --- plugins/modules/azure_rm_manageddisk.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/azure_rm_manageddisk.py b/plugins/modules/azure_rm_manageddisk.py index 584ed33fc..c5c170e86 100644 --- a/plugins/modules/azure_rm_manageddisk.py +++ b/plugins/modules/azure_rm_manageddisk.py @@ -442,7 +442,7 @@ def is_different(self, found_disk, new_disk): if not found_disk['disk_size_gb'] == new_disk['disk_size_gb']: resp = True if new_disk.get('os_type'): - if not found_disk['os_type'] == new_disk['os_type']: + if not self.compute_models.OperatingSystemTypes(found_disk['os_type'].capitalize()) == new_disk['os_type']: resp = True if new_disk.get('sku'): if not found_disk['storage_account_type'] == new_disk['sku'].name: From d4004edc6cd46950547888aa5aae3110d8838429 Mon Sep 17 00:00:00 2001 From: Maxence Date: Fri, 27 Aug 2021 21:36:33 +0000 Subject: [PATCH 2/3] Update str to OperatingSystemTypes conversion, leveraging the sdk capabilities --- plugins/modules/azure_rm_manageddisk.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/plugins/modules/azure_rm_manageddisk.py b/plugins/modules/azure_rm_manageddisk.py index c5c170e86..563d88974 100644 --- a/plugins/modules/azure_rm_manageddisk.py +++ b/plugins/modules/azure_rm_manageddisk.py @@ -413,11 +413,7 @@ def generate_managed_disk_property(self): creation_data['create_option'] = self.compute_models.DiskCreateOption.copy creation_data['source_resource_id'] = self.source_uri if self.os_type: - typecon = { - 'linux': self.compute_models.OperatingSystemTypes.linux, - 'windows': self.compute_models.OperatingSystemTypes.windows - } - disk_params['os_type'] = typecon[self.os_type] + disk_params['os_type'] = self.compute_models.OperatingSystemTypes(self.os_type.capitalize()) else: disk_params['os_type'] = None disk_params['creation_data'] = creation_data From 24db5e8d5d2837c30e09d11fb2ec851070d629f7 Mon Sep 17 00:00:00 2001 From: Maxence Date: Fri, 27 Aug 2021 21:51:32 +0000 Subject: [PATCH 3/3] Fix bug in os_type comparison when curren os_type is None --- plugins/modules/azure_rm_manageddisk.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/azure_rm_manageddisk.py b/plugins/modules/azure_rm_manageddisk.py index 563d88974..82a53f192 100644 --- a/plugins/modules/azure_rm_manageddisk.py +++ b/plugins/modules/azure_rm_manageddisk.py @@ -438,7 +438,7 @@ def is_different(self, found_disk, new_disk): if not found_disk['disk_size_gb'] == new_disk['disk_size_gb']: resp = True if new_disk.get('os_type'): - if not self.compute_models.OperatingSystemTypes(found_disk['os_type'].capitalize()) == new_disk['os_type']: + if found_disk['os_type'] is None or not self.compute_models.OperatingSystemTypes(found_disk['os_type'].capitalize()) == new_disk['os_type']: resp = True if new_disk.get('sku'): if not found_disk['storage_account_type'] == new_disk['sku'].name: