From 454096ca59fdaddcf9e5ac850bb20f6b91837c3a Mon Sep 17 00:00:00 2001 From: Yuwei Zhou Date: Wed, 28 Mar 2018 11:10:29 +0800 Subject: [PATCH] Fixes #37700 Azure image can be created with tag (#37981) * image can be create or add * update tags * can remove all tags * Update azure_rm_common.py --- lib/ansible/modules/cloud/azure/azure_rm_image.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/ansible/modules/cloud/azure/azure_rm_image.py b/lib/ansible/modules/cloud/azure/azure_rm_image.py index 0512d5d636..cf5e7841f1 100644 --- a/lib/ansible/modules/cloud/azure/azure_rm_image.py +++ b/lib/ansible/modules/cloud/azure/azure_rm_image.py @@ -135,13 +135,12 @@ class AzureRMImage(AzureRMModuleBase): self.source = None self.data_disk_sources = None self.os_type = None - self.tags = None super(AzureRMImage, self).__init__(self.module_arg_spec, supports_check_mode=True, required_if=required_if) def exec_module(self, **kwargs): - for key in self.module_arg_spec: + for key in list(self.module_arg_spec.keys()) + ['tags']: setattr(self, key, kwargs[key]) results = None @@ -158,7 +157,11 @@ class AzureRMImage(AzureRMModuleBase): if image: self.check_provisioning_state(image, self.state) results = image.id - # update is not supported + # update is not supported except for tags + update_tags, tags = self.update_tags(image.tags) + if update_tags: + changed = True + self.tags = tags if self.state == 'absent': changed = True # the image does not exist and create a new one