adding tags to azure_rm_sqldatabase (#52615)

* adding tags to sql database

* can't add version_added, so have to ignore sanity test

* removed ignore
This commit is contained in:
Zim Kalinowski 2019-02-21 08:17:45 +08:00 committed by Matt Davis
parent 20a96bcc4e
commit 4292c33649
2 changed files with 12 additions and 2 deletions

View file

@ -135,6 +135,7 @@ options:
extends_documentation_fragment:
- azure
- azure_tags
author:
- "Zim Kalinowski (@zikalino)"
@ -301,6 +302,7 @@ class AzureRMDatabases(AzureRMModuleBase):
self.server_name = None
self.name = None
self.parameters = dict()
self.tags = None
self.results = dict(changed=False)
self.state = None
@ -308,12 +310,12 @@ class AzureRMDatabases(AzureRMModuleBase):
super(AzureRMDatabases, self).__init__(derived_arg_spec=self.module_arg_spec,
supports_check_mode=True,
supports_tags=False)
supports_tags=True)
def exec_module(self, **kwargs):
"""Main module execution method"""
for key in list(self.module_arg_spec.keys()):
for key in list(self.module_arg_spec.keys()) + ['tags']:
if hasattr(self, key):
setattr(self, key, kwargs[key])
elif kwargs[key] is not None:
@ -380,6 +382,9 @@ class AzureRMDatabases(AzureRMModuleBase):
if (('edition' in self.parameters) and
(self.parameters['edition'] != old_response['edition'])):
self.to_do = Actions.Update
update_tags, newtags = self.update_tags(old_response.get('tags', dict()))
if update_tags:
self.tags = newtags
if (self.to_do == Actions.Create) or (self.to_do == Actions.Update):
self.log("Need to Create / Update the SQL Database instance")
@ -388,6 +393,7 @@ class AzureRMDatabases(AzureRMModuleBase):
self.results['changed'] = True
return self.results
self.parameters['tags'] = self.tags
response = self.create_update_sqldatabase()
if not old_response:

View file

@ -117,6 +117,8 @@
server_name: sqlsrv{{ random_postfix }}
name: database{{ random_postfix }}
location: eastus
tags:
aaa: bbb
register: output
- name: Assert the resource instance is well created
assert:
@ -130,6 +132,8 @@
server_name: sqlsrv{{ random_postfix }}
name: database{{ random_postfix }}
location: eastus
tags:
aaa: bbb
register: output
- name: Assert the state has not changed
assert: