diff --git a/plugins/modules/azure_rm_servicebus.py b/plugins/modules/azure_rm_servicebus.py index f3f57cf5c..07db88849 100644 --- a/plugins/modules/azure_rm_servicebus.py +++ b/plugins/modules/azure_rm_servicebus.py @@ -57,6 +57,8 @@ azure_rm_servicebus: name: deadbeef location: eastus + tags: + key1: value1 ''' RETURN = ''' id: @@ -102,11 +104,12 @@ def __init__(self): ) super(AzureRMServiceBus, self).__init__(self.module_arg_spec, + supports_tags=True, supports_check_mode=True) def exec_module(self, **kwargs): - for key in list(self.module_arg_spec.keys()): + for key in list(self.module_arg_spec.keys()) + ['tags']: setattr(self, key, kwargs[key]) changed = False @@ -116,11 +119,25 @@ def exec_module(self, **kwargs): self.location = resource_group.location original = self.get() - if self.state == 'present' and not original: + + if not original: self.check_name() - changed = True + + if self.state == 'present': if not self.check_mode: - original = self.create() + if original: + update_tags, new_tags = self.update_tags(original.tags) + if update_tags: + changed = True + self.tags = new_tags + original = self.create() + else: + changed = False + else: + changed = True + original = self.create() + else: + changed = True elif self.state == 'absent' and original: changed = True original = None @@ -148,6 +165,7 @@ def create(self): poller = self.servicebus_client.namespaces.begin_create_or_update(self.resource_group, self.name, self.servicebus_models.SBNamespace(location=self.location, + tags=self.tags, sku=sku)) ns = self.get_poller_result(poller) except Exception as exc: diff --git a/plugins/modules/azure_rm_servicebusqueue.py b/plugins/modules/azure_rm_servicebusqueue.py index a86abc49b..f50693cf3 100644 --- a/plugins/modules/azure_rm_servicebusqueue.py +++ b/plugins/modules/azure_rm_servicebusqueue.py @@ -108,7 +108,6 @@ - receive_disabled extends_documentation_fragment: - azure.azcollection.azure - - azure.azcollection.azure_tags author: - Yuwei Zhou (@yuwzho) @@ -214,6 +213,7 @@ def __init__(self): ) super(AzureRMServiceBusQueue, self).__init__(self.module_arg_spec, + supports_tags=False, supports_check_mode=True) def exec_module(self, **kwargs): diff --git a/plugins/modules/azure_rm_servicebussaspolicy.py b/plugins/modules/azure_rm_servicebussaspolicy.py index 0808ee338..3acb2f479 100644 --- a/plugins/modules/azure_rm_servicebussaspolicy.py +++ b/plugins/modules/azure_rm_servicebussaspolicy.py @@ -66,7 +66,6 @@ extends_documentation_fragment: - azure.azcollection.azure - - azure.azcollection.azure_tags author: - Yuwei Zhou (@yuwzho) @@ -199,6 +198,7 @@ def __init__(self): super(AzureRMServiceBusSASPolicy, self).__init__(self.module_arg_spec, mutually_exclusive=mutually_exclusive, required_if=required_if, + supports_tags=False, supports_check_mode=True) def exec_module(self, **kwargs): diff --git a/plugins/modules/azure_rm_servicebustopic.py b/plugins/modules/azure_rm_servicebustopic.py index 11937cecf..8d81d0f22 100644 --- a/plugins/modules/azure_rm_servicebustopic.py +++ b/plugins/modules/azure_rm_servicebustopic.py @@ -88,7 +88,6 @@ extends_documentation_fragment: - azure.azcollection.azure - - azure.azcollection.azure_tags author: - Yuwei Zhou (@yuwzho) @@ -180,6 +179,7 @@ def __init__(self): ) super(AzureRMServiceBusTopic, self).__init__(self.module_arg_spec, + supports_tags=False, supports_check_mode=True) def exec_module(self, **kwargs): diff --git a/plugins/modules/azure_rm_servicebustopicsubscription.py b/plugins/modules/azure_rm_servicebustopicsubscription.py index ea9ef1d56..b6cc523db 100644 --- a/plugins/modules/azure_rm_servicebustopicsubscription.py +++ b/plugins/modules/azure_rm_servicebustopicsubscription.py @@ -100,7 +100,6 @@ extends_documentation_fragment: - azure.azcollection.azure - - azure.azcollection.azure_tags author: - Yuwei Zhou (@yuwzho) @@ -193,6 +192,7 @@ def __init__(self): ) super(AzureRMServiceSubscription, self).__init__(self.module_arg_spec, + supports_tags=False, supports_check_mode=True) def exec_module(self, **kwargs): diff --git a/tests/integration/targets/azure_rm_servicebus/tasks/main.yml b/tests/integration/targets/azure_rm_servicebus/tasks/main.yml index 93f56ebb2..11c2208aa 100644 --- a/tests/integration/targets/azure_rm_servicebus/tasks/main.yml +++ b/tests/integration/targets/azure_rm_servicebus/tasks/main.yml @@ -7,12 +7,15 @@ azure_rm_servicebus: name: "ns{{ rpfx }}" resource_group: "{{ resource_group }}" + tags: + key1: value1 register: namespace - assert: that: - namespace.id - namespace.changed + - namespace.tags - name: Create a namespace (idempontent) azure_rm_servicebus: @@ -166,4 +169,4 @@ azure_rm_servicebus: name: "ns{{ rpfx }}" resource_group: "{{ resource_group }}" - state: absent \ No newline at end of file + state: absent