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
OpenEdx
configuration
Commits
3cec6c0a
Commit
3cec6c0a
authored
Aug 18, 2014
by
e0d
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1418 from edx/e0d/lifecycle-inventory
initial working version
parents
134935a7
5653f338
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
101 additions
and
0 deletions
+101
-0
playbooks/edx-east/lifecycle_inventory.py
+83
-0
playbooks/roles/aws/templates/edx/etc/minos.yml
+18
-0
No files found.
playbooks/edx-east/lifecycle_inventory.py
0 → 100755
View file @
3cec6c0a
#!/usr/bin/env python
"""
Build an ansible inventory based on autoscaling group instance lifecycle state.
Outputs JSON to stdout with keys for each state and combination of autoscaling
group and state.
{
"InService": [
"10.0.47.127",
"10.0.46.174"
],
"Terminating:Wait": [
"10.0.48.104"
],
"e-d-CommonClusterServerAsGroup": [
"10.0.47.127",
"10.0.46.174"
],
"e-d-CommonClusterServerAsGroup_InService": [
"10.0.47.127",
"10.0.46.174"
],
"e-d-CommonClusterServerAsGroup_InService": [
"10.0.48.104"
]
}
"""
import
argparse
import
boto
import
json
from
collections
import
defaultdict
class
LifecycleInventory
():
profile
=
None
def
__init__
(
self
,
profile
):
parser
=
argparse
.
ArgumentParser
()
self
.
profile
=
profile
def
get_instance_dict
(
self
):
ec2
=
boto
.
connect_ec2
(
profile_name
=
self
.
profile
)
reservations
=
ec2
.
get_all_instances
()
dict
=
{}
for
instance
in
[
i
for
r
in
reservations
for
i
in
r
.
instances
]:
dict
[
instance
.
id
]
=
instance
return
dict
def
run
(
self
):
autoscale
=
boto
.
connect_autoscale
(
profile_name
=
self
.
profile
)
groups
=
autoscale
.
get_all_groups
()
instances
=
self
.
get_instance_dict
()
inventory
=
defaultdict
(
list
)
for
group
in
groups
:
for
instance
in
group
.
instances
:
private_ip_address
=
instances
[
instance
.
instance_id
]
.
private_ip_address
inventory
[
group
.
name
]
.
append
(
private_ip_address
)
inventory
[
group
.
name
+
"_"
+
instance
.
lifecycle_state
]
.
append
(
private_ip_address
)
inventory
[
instance
.
lifecycle_state
]
.
append
(
private_ip_address
)
print
json
.
dumps
(
inventory
,
sort_keys
=
True
,
indent
=
2
)
if
__name__
==
"__main__"
:
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'-p'
,
'--profile'
,
help
=
'The aws profile to use when connecting.'
)
args
=
parser
.
parse_args
()
LifecycleInventory
(
args
.
profile
)
.
run
()
playbooks/roles/aws/templates/edx/etc/minos.yml
0 → 100644
View file @
3cec6c0a
---
aws_profile
:
!!null
s3_bucket
:
'
edx-prod-edx'
bucket_path
:
'
test'
voters
:
-
BellwetherVoter
:
config
:
-
ProccessQuienscenceVoter
:
config
:
process_name
:
'
gunicorn'
-
TrackingLogVoter
:
config
:
aws_profile
:
!!null
s3_bucket
:
'
edx-prod-edx'
bucket_path
:
'
test'
local_directory
:
'
{{
COMMON_LOG_DIR
}}'
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