[cloud] ec2_group: fix check mode when using tags (#36503)
Fixes #36412
This commit is contained in:
parent
cb73fba369
commit
54f9f06edc
1 changed files with 11 additions and 9 deletions
|
@ -789,10 +789,11 @@ def main():
|
|||
|
||||
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', []))
|
||||
tags_need_modify, tags_to_delete = compare_aws_tags(current_tags, tags, purge_tags)
|
||||
if tags_to_delete:
|
||||
if not module.check_mode:
|
||||
try:
|
||||
client.delete_tags(Resources=[group['GroupId']], Tags=[{'Key': tag} for tag in tags_to_delete])
|
||||
except botocore.exceptions.ClientError as e:
|
||||
|
@ -801,6 +802,7 @@ def main():
|
|||
|
||||
# Add/update tags
|
||||
if tags_need_modify:
|
||||
if not module.check_mode:
|
||||
try:
|
||||
client.create_tags(Resources=[group['GroupId']], Tags=ansible_dict_to_boto3_tag_list(tags_need_modify))
|
||||
except botocore.exceptions.ClientError as e:
|
||||
|
|
Loading…
Reference in a new issue