1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

[cloud] ec2_asg: check autoscaling group for tags before trying to use them - partially fixes #23234 (#23259)

* check autoscaling group for tags before trying to use them

* Add warning

fix comparison
This commit is contained in:
Sloane Hertel 2017-04-11 16:15:05 -04:00 committed by Ryan Brown
parent 5f517fdfa9
commit 2f64e2c7fb

View file

@ -551,11 +551,14 @@ def create_autoscaling_group(connection, module):
want_tags[tag.key] = [tag.value, tag.propagate_at_launch] want_tags[tag.key] = [tag.value, tag.propagate_at_launch]
dead_tags = [] dead_tags = []
for tag in as_group.tags: if getattr(as_group, "tags", None):
have_tags[tag.key] = [tag.value, tag.propagate_at_launch] for tag in as_group.tags:
if tag.key not in want_tags: have_tags[tag.key] = [tag.value, tag.propagate_at_launch]
changed = True if tag.key not in want_tags:
dead_tags.append(tag) changed = True
dead_tags.append(tag)
elif getattr(as_group, "tags", None) is None and asg_tags:
module.warn("It appears your ASG is attached to a target group. This is a boto2 bug. Tags will be added but no tags are able to be removed.")
if dead_tags != []: if dead_tags != []:
connection.delete_tags(dead_tags) connection.delete_tags(dead_tags)