mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Merge branch 'jsmartin-asg_update' into devel
This commit is contained in:
commit
b8783c7555
1 changed files with 36 additions and 14 deletions
|
@ -69,7 +69,7 @@ options:
|
||||||
default: None
|
default: None
|
||||||
tags:
|
tags:
|
||||||
description:
|
description:
|
||||||
- List of tag dictionaries to use. Required keys are 'key', 'value'. Optional key is 'propagate_at_launch', which defaults to true.
|
- A list of tags to add to the Auto Scale Group. Optional key is 'propagate_at_launch', which defaults to true.
|
||||||
required: false
|
required: false
|
||||||
default: None
|
default: None
|
||||||
version_added: "1.7"
|
version_added: "1.7"
|
||||||
|
@ -99,6 +99,11 @@ EXAMPLES = '''
|
||||||
max_size: 10
|
max_size: 10
|
||||||
desired_capacity: 5
|
desired_capacity: 5
|
||||||
vpc_zone_identifier: 'subnet-abcd1234,subnet-1a2b3c4d'
|
vpc_zone_identifier: 'subnet-abcd1234,subnet-1a2b3c4d'
|
||||||
|
tags:
|
||||||
|
- environment: production
|
||||||
|
propagate_at_launch: no
|
||||||
|
|
||||||
|
deprecated method of expressing tags:
|
||||||
tags:
|
tags:
|
||||||
- key: environment
|
- key: environment
|
||||||
value: production
|
value: production
|
||||||
|
@ -169,10 +174,18 @@ def create_autoscaling_group(connection, module):
|
||||||
|
|
||||||
asg_tags = []
|
asg_tags = []
|
||||||
for tag in set_tags:
|
for tag in set_tags:
|
||||||
|
if tag.has_key('key') and tag.has_key('value'): # this block is to support depricated form
|
||||||
asg_tags.append(Tag(key=tag.get('key'),
|
asg_tags.append(Tag(key=tag.get('key'),
|
||||||
value=tag.get('value'),
|
value=tag.get('value'),
|
||||||
propagate_at_launch=bool(tag.get('propagate_at_launch', True)),
|
propagate_at_launch=bool(tag.get('propagate_at_launch', True)),
|
||||||
resource_id=group_name))
|
resource_id=group_name))
|
||||||
|
else:
|
||||||
|
for k,v in tag.iteritems():
|
||||||
|
if k !='propagate_at_launch':
|
||||||
|
asg_tags.append(Tag(key=k,
|
||||||
|
value=v,
|
||||||
|
propagate_at_launch=bool(tag.get('propagate_at_launch', True)),
|
||||||
|
resource_id=group_name))
|
||||||
|
|
||||||
if not as_groups:
|
if not as_groups:
|
||||||
if not vpc_zone_identifier and not availability_zones:
|
if not vpc_zone_identifier and not availability_zones:
|
||||||
|
@ -211,13 +224,22 @@ def create_autoscaling_group(connection, module):
|
||||||
existing_tags = as_group.tags
|
existing_tags = as_group.tags
|
||||||
existing_tag_map = dict((tag.key, tag) for tag in existing_tags)
|
existing_tag_map = dict((tag.key, tag) for tag in existing_tags)
|
||||||
for tag in set_tags:
|
for tag in set_tags:
|
||||||
|
if tag.has_key('key') and tag.has_key('value'): # this is to support deprecated method
|
||||||
if 'key' not in tag:
|
if 'key' not in tag:
|
||||||
continue
|
continue
|
||||||
if ( not tag['key'] in existing_tag_map or
|
if ( not tag['key'] in existing_tag_map or
|
||||||
existing_tag_map[tag['key']].value != tag['value'] or
|
existing_tag_map[tag['key']].value != tag['value'] or
|
||||||
('propagate_at_launch' in tag and
|
('propagate_at_launch' in tag and
|
||||||
existing_tag_map[tag['key']].propagate_at_launch != tag['propagate_at_launch']) ):
|
existing_tag_map[tag['key']].propagate_at_launch != tag['propagate_at_launch']) ):
|
||||||
|
changed = True
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
for k,v in tag.iteritems():
|
||||||
|
if k !='propagate_at_launch':
|
||||||
|
if ( not k in existing_tag_map or
|
||||||
|
existing_tag_map[k].value != v or
|
||||||
|
('propagate_at_launch' in tag and
|
||||||
|
existing_tag_map[k].propagate_at_launch != tag['propagate_at_launch']) ):
|
||||||
changed = True
|
changed = True
|
||||||
continue
|
continue
|
||||||
if changed:
|
if changed:
|
||||||
|
|
Loading…
Reference in a new issue