mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
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:
parent
20a96bcc4e
commit
4292c33649
2 changed files with 12 additions and 2 deletions
|
@ -135,6 +135,7 @@ options:
|
||||||
|
|
||||||
extends_documentation_fragment:
|
extends_documentation_fragment:
|
||||||
- azure
|
- azure
|
||||||
|
- azure_tags
|
||||||
|
|
||||||
author:
|
author:
|
||||||
- "Zim Kalinowski (@zikalino)"
|
- "Zim Kalinowski (@zikalino)"
|
||||||
|
@ -301,6 +302,7 @@ class AzureRMDatabases(AzureRMModuleBase):
|
||||||
self.server_name = None
|
self.server_name = None
|
||||||
self.name = None
|
self.name = None
|
||||||
self.parameters = dict()
|
self.parameters = dict()
|
||||||
|
self.tags = None
|
||||||
|
|
||||||
self.results = dict(changed=False)
|
self.results = dict(changed=False)
|
||||||
self.state = None
|
self.state = None
|
||||||
|
@ -308,12 +310,12 @@ class AzureRMDatabases(AzureRMModuleBase):
|
||||||
|
|
||||||
super(AzureRMDatabases, self).__init__(derived_arg_spec=self.module_arg_spec,
|
super(AzureRMDatabases, self).__init__(derived_arg_spec=self.module_arg_spec,
|
||||||
supports_check_mode=True,
|
supports_check_mode=True,
|
||||||
supports_tags=False)
|
supports_tags=True)
|
||||||
|
|
||||||
def exec_module(self, **kwargs):
|
def exec_module(self, **kwargs):
|
||||||
"""Main module execution method"""
|
"""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):
|
if hasattr(self, key):
|
||||||
setattr(self, key, kwargs[key])
|
setattr(self, key, kwargs[key])
|
||||||
elif kwargs[key] is not None:
|
elif kwargs[key] is not None:
|
||||||
|
@ -380,6 +382,9 @@ class AzureRMDatabases(AzureRMModuleBase):
|
||||||
if (('edition' in self.parameters) and
|
if (('edition' in self.parameters) and
|
||||||
(self.parameters['edition'] != old_response['edition'])):
|
(self.parameters['edition'] != old_response['edition'])):
|
||||||
self.to_do = Actions.Update
|
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):
|
if (self.to_do == Actions.Create) or (self.to_do == Actions.Update):
|
||||||
self.log("Need to Create / Update the SQL Database instance")
|
self.log("Need to Create / Update the SQL Database instance")
|
||||||
|
@ -388,6 +393,7 @@ class AzureRMDatabases(AzureRMModuleBase):
|
||||||
self.results['changed'] = True
|
self.results['changed'] = True
|
||||||
return self.results
|
return self.results
|
||||||
|
|
||||||
|
self.parameters['tags'] = self.tags
|
||||||
response = self.create_update_sqldatabase()
|
response = self.create_update_sqldatabase()
|
||||||
|
|
||||||
if not old_response:
|
if not old_response:
|
||||||
|
|
|
@ -117,6 +117,8 @@
|
||||||
server_name: sqlsrv{{ random_postfix }}
|
server_name: sqlsrv{{ random_postfix }}
|
||||||
name: database{{ random_postfix }}
|
name: database{{ random_postfix }}
|
||||||
location: eastus
|
location: eastus
|
||||||
|
tags:
|
||||||
|
aaa: bbb
|
||||||
register: output
|
register: output
|
||||||
- name: Assert the resource instance is well created
|
- name: Assert the resource instance is well created
|
||||||
assert:
|
assert:
|
||||||
|
@ -130,6 +132,8 @@
|
||||||
server_name: sqlsrv{{ random_postfix }}
|
server_name: sqlsrv{{ random_postfix }}
|
||||||
name: database{{ random_postfix }}
|
name: database{{ random_postfix }}
|
||||||
location: eastus
|
location: eastus
|
||||||
|
tags:
|
||||||
|
aaa: bbb
|
||||||
register: output
|
register: output
|
||||||
- name: Assert the state has not changed
|
- name: Assert the state has not changed
|
||||||
assert:
|
assert:
|
||||||
|
|
Loading…
Reference in a new issue