Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
configuration
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
edx
configuration
Commits
52bf8918
Commit
52bf8918
authored
Oct 26, 2015
by
Feanil Patel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make tagging work with new tag input format for ec2_asg
parent
67592ec2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
2 deletions
+37
-2
playbooks/edx-east/edx_service.yml
+10
-2
playbooks/library/util_map
+27
-0
No files found.
playbooks/edx-east/edx_service.yml
View file @
52bf8918
...
...
@@ -163,19 +163,27 @@
-
debug
:
msg="{{ created_service_subnets.results|map(attribute='subnet_id')| list | join(',') }}"
register
:
service_vpc_zone_identifier_string
-
name
:
Transform tags into list dict format for the modules that expect it
util_map
:
function
:
zip_to_listdict
input
:
"
{{
asg_instance_tags
}}"
args
:
[
'
key'
,
'
value'
]
register
:
listdict_asg_instance_tags
-
debug
:
msg="Instance Tags:{{ listdict_asg_instance_tags }}"
-
name
:
Manage ASG
ec2_asg
:
profile
:
"
{{
profile
}}"
region
:
"
{{
aws_region
}}"
name
:
"
{{
asg_name
}}"
launch_config_name
:
"
{{
service_config.name
}}"
load_balancers
:
"
{{
elb_name
}}"
availability_zones
:
"
{{
aws_availability_zones
}}"
min_size
:
"
{{
asg_min_size
}}"
max_size
:
"
{{
asg_max_size
}}"
desired_capacity
:
"
{{
asg_desired_capacity
}}"
vpc_zone_identifier
:
"
{{
service_vpc_zone_identifier_string.msg
}}"
tags
:
"
{{
asg_instance_tags
}}"
tags
:
"
{{
listdict_asg_instance_tags.function_output
}}"
load_balancers
:
"
{{
created_elbs.results|map(attribute='elb.name')|list
}}"
register
:
asg
when
:
auto_scaling_service
...
...
playbooks/library/util_map
View file @
52bf8918
...
...
@@ -130,6 +130,31 @@ def zip_to_list(module, input, key):
module
.
exit_json
(
function_output
=
results
)
def
zip_to_listdict
(
module
,
input
,
key_name
,
value_name
):
"""
Take an array of dicts and build a list of dicts where the name of the key
is taken as a value of one of the keys in the input list and the vaule is
the value of a different key.
For example with an input like
[{'tag_name': 'Name', 'tag_value': 'stage-edx-edxapp'}, {'tag_name': 'cluster', 'tag_value': 'edxapp'}]
and an args array of ['tag_name', 'tag_value']
would return
[{'Name': 'stage-edx-edxapp'}, {'cluster': 'edxapp'}]
NB: This is used to work around the fact that we can template out the names
of keys in dictionaries in ansible.
"""
results
=
[]
for
item
in
input
:
results
.
append
({
item
[
key_name
]:
item
[
value_name
]})
module
.
exit_json
(
function_output
=
results
)
def
main
():
arg_spec
=
dict
(
...
...
@@ -151,6 +176,8 @@ def main():
flatten
(
module
,
input
)
elif
target
==
'zip_to_list'
:
zip_to_list
(
module
,
input
,
*
args
)
elif
target
==
'zip_to_listdict'
:
zip_to_listdict
(
module
,
input
,
*
args
)
else
:
raise
NotImplemented
(
"Function {0} is not implemented."
.
format
(
target
))
...
...
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