mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
[cloud] ec2_group: fix check mode when using tags (#36503)
Fixes #36412
This commit is contained in:
parent
51ba115dea
commit
a77b89e7b5
1 changed files with 11 additions and 9 deletions
|
@ -789,22 +789,24 @@ def main():
|
||||||
|
|
||||||
changed = True
|
changed = True
|
||||||
|
|
||||||
if tags is not None:
|
if tags is not None and group is not None:
|
||||||
current_tags = boto3_tag_list_to_ansible_dict(group.get('Tags', []))
|
current_tags = boto3_tag_list_to_ansible_dict(group.get('Tags', []))
|
||||||
tags_need_modify, tags_to_delete = compare_aws_tags(current_tags, tags, purge_tags)
|
tags_need_modify, tags_to_delete = compare_aws_tags(current_tags, tags, purge_tags)
|
||||||
if tags_to_delete:
|
if tags_to_delete:
|
||||||
try:
|
if not module.check_mode:
|
||||||
client.delete_tags(Resources=[group['GroupId']], Tags=[{'Key': tag} for tag in tags_to_delete])
|
try:
|
||||||
except botocore.exceptions.ClientError as e:
|
client.delete_tags(Resources=[group['GroupId']], Tags=[{'Key': tag} for tag in tags_to_delete])
|
||||||
module.fail_json(msg=e.message, exception=traceback.format_exc(), **camel_dict_to_snake_dict(e.response))
|
except botocore.exceptions.ClientError as e:
|
||||||
|
module.fail_json(msg=e.message, exception=traceback.format_exc(), **camel_dict_to_snake_dict(e.response))
|
||||||
changed = True
|
changed = True
|
||||||
|
|
||||||
# Add/update tags
|
# Add/update tags
|
||||||
if tags_need_modify:
|
if tags_need_modify:
|
||||||
try:
|
if not module.check_mode:
|
||||||
client.create_tags(Resources=[group['GroupId']], Tags=ansible_dict_to_boto3_tag_list(tags_need_modify))
|
try:
|
||||||
except botocore.exceptions.ClientError as e:
|
client.create_tags(Resources=[group['GroupId']], Tags=ansible_dict_to_boto3_tag_list(tags_need_modify))
|
||||||
module.fail_json(msg=e.message, exception=traceback.format_exc(), **camel_dict_to_snake_dict(e.response))
|
except botocore.exceptions.ClientError as e:
|
||||||
|
module.fail_json(msg=e.message, exception=traceback.format_exc(), **camel_dict_to_snake_dict(e.response))
|
||||||
changed = True
|
changed = True
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue