1
0
Fork 0
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:
Zim Kalinowski 2018-09-04 15:56:10 +08:00 committed by ansibot
parent 455dfbe732
commit e7ec1ef59c

View file

@ -97,6 +97,7 @@ options:
extends_documentation_fragment:
- azure
- azure_tags
author:
- "Zim Kalinowski (@zikalino)"
@ -256,17 +257,19 @@ class AzureRMContainerInstance(AzureRMModuleBase):
self.containers = None
self.tags = None
self.results = dict(changed=False, state=dict())
self.cgmodels = None
super(AzureRMContainerInstance, 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']:
setattr(self, key, kwargs[key])
resource_group = None
@ -300,6 +303,10 @@ class AzureRMContainerInstance(AzureRMModuleBase):
self.log("Container instance deleted")
elif self.state == 'present':
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:
self.log('Deleting container instance before update')
if not self.check_mode:
@ -375,7 +382,8 @@ class AzureRMContainerInstance(AzureRMModuleBase):
restart_policy=None,
ip_address=ip_address,
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,
container_group_name=self.name,