Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
d398dc1b
Commit
d398dc1b
authored
Aug 05, 2014
by
James Cammarata
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'asg_update' of
https://github.com/jsmartin/ansible
into jsmartin-asg_update
parents
2d84a9d3
e36ef4de
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
14 deletions
+36
-14
library/cloud/ec2_asg
+36
-14
No files found.
library/cloud/ec2_asg
View file @
d398dc1b
...
...
@@ -69,7 +69,7 @@ options:
default: None
tags:
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
default: None
version_added: "1.7"
...
...
@@ -100,6 +100,11 @@ EXAMPLES = '''
desired_capacity: 5
vpc_zone_identifier: 'subnet-abcd1234,subnet-1a2b3c4d'
tags:
- environment: production
propagate_at_launch: no
deprecated method of expressing tags:
tags:
- key: environment
value: production
propagate_at_launch: no
...
...
@@ -169,10 +174,18 @@ def create_autoscaling_group(connection, module):
asg_tags
=
[]
for
tag
in
set_tags
:
asg_tags
.
append
(
Tag
(
key
=
tag
.
get
(
'key'
),
value
=
tag
.
get
(
'value'
),
propagate_at_launch
=
bool
(
tag
.
get
(
'propagate_at_launch'
,
True
)),
resource_id
=
group_name
))
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'
),
value
=
tag
.
get
(
'value'
),
propagate_at_launch
=
bool
(
tag
.
get
(
'propagate_at_launch'
,
True
)),
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
vpc_zone_identifier
and
not
availability_zones
:
...
...
@@ -211,15 +224,24 @@ def create_autoscaling_group(connection, module):
existing_tags
=
as_group
.
tags
existing_tag_map
=
dict
((
tag
.
key
,
tag
)
for
tag
in
existing_tags
)
for
tag
in
set_tags
:
if
'key'
not
in
tag
:
continue
if
(
not
tag
[
'key'
]
in
existing_tag_map
or
existing_tag_map
[
tag
[
'key'
]]
.
value
!=
tag
[
'value'
]
or
(
'propagate_at_launch'
in
tag
and
existing_tag_map
[
tag
[
'key'
]]
.
propagate_at_launch
!=
tag
[
'propagate_at_launch'
])
):
changed
=
True
continue
if
tag
.
has_key
(
'key'
)
and
tag
.
has_key
(
'value'
):
# this is to support deprecated method
if
'key'
not
in
tag
:
continue
if
(
not
tag
[
'key'
]
in
existing_tag_map
or
existing_tag_map
[
tag
[
'key'
]]
.
value
!=
tag
[
'value'
]
or
(
'propagate_at_launch'
in
tag
and
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
continue
if
changed
:
connection
.
create_or_update_tags
(
asg_tags
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment