mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-24 13:50:22 -07:00
adding tags to keyvault (#45145)
This commit is contained in:
parent
9c1ba18607
commit
a5e2b60870
2 changed files with 28 additions and 3 deletions
|
@ -152,6 +152,7 @@ options:
|
|||
|
||||
extends_documentation_fragment:
|
||||
- azure
|
||||
- azure_tags
|
||||
|
||||
author:
|
||||
- "Zim Kalinowski (@zikalino)"
|
||||
|
@ -265,6 +266,7 @@ class AzureRMVaults(AzureRMModuleBase):
|
|||
self.resource_group = None
|
||||
self.vault_name = None
|
||||
self.parameters = dict()
|
||||
self.tags = None
|
||||
|
||||
self.results = dict(changed=False)
|
||||
self.mgmt_client = None
|
||||
|
@ -273,14 +275,14 @@ class AzureRMVaults(AzureRMModuleBase):
|
|||
|
||||
super(AzureRMVaults, self).__init__(derived_arg_spec=self.module_arg_spec,
|
||||
supports_check_mode=True,
|
||||
supports_tags=False,
|
||||
supports_tags=True,
|
||||
required_if=self.module_required_if)
|
||||
|
||||
def exec_module(self, **kwargs):
|
||||
"""Main module execution method"""
|
||||
|
||||
# translate Ansible input to SDK-formatted dict in self.parameters
|
||||
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:
|
||||
|
@ -391,6 +393,12 @@ class AzureRMVaults(AzureRMModuleBase):
|
|||
self.to_do = Actions.Update
|
||||
break
|
||||
|
||||
update_tags, newtags = self.update_tags(old_response.get('tags', dict()))
|
||||
|
||||
if update_tags:
|
||||
self.to_do = Actions.Update
|
||||
self.tags = newtags
|
||||
|
||||
if (self.to_do == Actions.Create) or (self.to_do == Actions.Update):
|
||||
self.log("Need to Create / Update the Key Vault instance")
|
||||
|
||||
|
@ -398,6 +406,8 @@ class AzureRMVaults(AzureRMModuleBase):
|
|||
self.results['changed'] = True
|
||||
return self.results
|
||||
|
||||
self.parameters["tags"] = self.tags
|
||||
|
||||
response = self.create_update_keyvault()
|
||||
|
||||
if not old_response:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue