mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
adding tags to container instance (#45142)
This commit is contained in:
parent
455dfbe732
commit
e7ec1ef59c
1 changed files with 11 additions and 3 deletions
|
@ -97,6 +97,7 @@ options:
|
||||||
|
|
||||||
extends_documentation_fragment:
|
extends_documentation_fragment:
|
||||||
- azure
|
- azure
|
||||||
|
- azure_tags
|
||||||
|
|
||||||
author:
|
author:
|
||||||
- "Zim Kalinowski (@zikalino)"
|
- "Zim Kalinowski (@zikalino)"
|
||||||
|
@ -256,17 +257,19 @@ class AzureRMContainerInstance(AzureRMModuleBase):
|
||||||
|
|
||||||
self.containers = None
|
self.containers = None
|
||||||
|
|
||||||
|
self.tags = None
|
||||||
|
|
||||||
self.results = dict(changed=False, state=dict())
|
self.results = dict(changed=False, state=dict())
|
||||||
self.cgmodels = None
|
self.cgmodels = None
|
||||||
|
|
||||||
super(AzureRMContainerInstance, self).__init__(derived_arg_spec=self.module_arg_spec,
|
super(AzureRMContainerInstance, 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']:
|
||||||
setattr(self, key, kwargs[key])
|
setattr(self, key, kwargs[key])
|
||||||
|
|
||||||
resource_group = None
|
resource_group = None
|
||||||
|
@ -300,6 +303,10 @@ class AzureRMContainerInstance(AzureRMModuleBase):
|
||||||
self.log("Container instance deleted")
|
self.log("Container instance deleted")
|
||||||
elif self.state == 'present':
|
elif self.state == 'present':
|
||||||
self.log("Need to check if container group has to be deleted or may be updated")
|
self.log("Need to check if container group has to be deleted or may be updated")
|
||||||
|
update_tags, newtags = self.update_tags(response.get('tags', dict()))
|
||||||
|
if update_tags:
|
||||||
|
self.tags = newtags
|
||||||
|
|
||||||
if self.force_update:
|
if self.force_update:
|
||||||
self.log('Deleting container instance before update')
|
self.log('Deleting container instance before update')
|
||||||
if not self.check_mode:
|
if not self.check_mode:
|
||||||
|
@ -375,7 +382,8 @@ class AzureRMContainerInstance(AzureRMModuleBase):
|
||||||
restart_policy=None,
|
restart_policy=None,
|
||||||
ip_address=ip_address,
|
ip_address=ip_address,
|
||||||
os_type=self.os_type,
|
os_type=self.os_type,
|
||||||
volumes=None)
|
volumes=None,
|
||||||
|
tags=self.tags)
|
||||||
|
|
||||||
response = self.containerinstance_client.container_groups.create_or_update(resource_group_name=self.resource_group,
|
response = self.containerinstance_client.container_groups.create_or_update(resource_group_name=self.resource_group,
|
||||||
container_group_name=self.name,
|
container_group_name=self.name,
|
||||||
|
|
Loading…
Reference in a new issue