Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support tags to azure_rm_servicebus.py #1114

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions plugins/modules/azure_rm_servicebus.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
azure_rm_servicebus:
name: deadbeef
location: eastus
tags:
key1: value1
'''
RETURN = '''
id:
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/azure_rm_servicebusqueue.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@
- receive_disabled
extends_documentation_fragment:
- azure.azcollection.azure
- azure.azcollection.azure_tags

author:
- Yuwei Zhou (@yuwzho)
Expand Down Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/azure_rm_servicebussaspolicy.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@

extends_documentation_fragment:
- azure.azcollection.azure
- azure.azcollection.azure_tags

author:
- Yuwei Zhou (@yuwzho)
Expand Down Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/azure_rm_servicebustopic.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@

extends_documentation_fragment:
- azure.azcollection.azure
- azure.azcollection.azure_tags

author:
- Yuwei Zhou (@yuwzho)
Expand Down Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/azure_rm_servicebustopicsubscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@

extends_documentation_fragment:
- azure.azcollection.azure
- azure.azcollection.azure_tags

author:
- Yuwei Zhou (@yuwzho)
Expand Down Expand Up @@ -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):
Expand Down
5 changes: 4 additions & 1 deletion tests/integration/targets/azure_rm_servicebus/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -166,4 +169,4 @@
azure_rm_servicebus:
name: "ns{{ rpfx }}"
resource_group: "{{ resource_group }}"
state: absent
state: absent