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
e0a5003b
Commit
e0a5003b
authored
Jul 11, 2015
by
Jason Young
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ability to specify any combination of EC2 instance states to return
parent
4203b699
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
2 deletions
+29
-2
contrib/inventory/ec2.ini
+5
-0
contrib/inventory/ec2.py
+24
-2
No files found.
contrib/inventory/ec2.ini
View file @
e0a5003b
...
...
@@ -58,6 +58,11 @@ route53 = False
# 'all_instances' to True to return all instances regardless of state.
all_instances
=
False
# By default, only EC2 instances in the 'running' state are returned. Specify
# EC2 instance states to return as a comma-separated list. This
# option is overriden when 'all_instances' is True.
# instance_states = pending, running, shutting-down, terminated, stopping, stopped
# By default, only RDS instances in the 'available' state are returned. Set
# 'all_rds_instances' to True return all RDS instances regardless of state.
all_rds_instances
=
False
...
...
contrib/inventory/ec2.py
View file @
e0a5003b
...
...
@@ -244,6 +244,28 @@ class Ec2Inventory(object):
else
:
self
.
all_instances
=
False
# Instance states to be gathered in inventory. Default is 'running'.
# Setting 'all_instances' to 'yes' overrides this option.
ec2_valid_instance_states
=
[
'pending'
,
'running'
,
'shutting-down'
,
'terminated'
,
'stopping'
,
'stopped'
]
self
.
ec2_instance_states
=
[]
if
self
.
all_instances
:
self
.
ec2_instance_states
=
ec2_valid_instance_states
elif
config
.
has_option
(
'ec2'
,
'instance_states'
):
for
instance_state
in
config
.
get
(
'ec2'
,
'instance_states'
)
.
split
(
','
):
instance_state
=
instance_state
.
strip
()
if
instance_state
not
in
ec2_valid_instance_states
:
continue
self
.
ec2_instance_states
.
append
(
instance_state
)
else
:
self
.
ec2_instance_states
=
[
'running'
]
# Return all RDS instances? (if RDS is enabled)
if
config
.
has_option
(
'ec2'
,
'all_rds_instances'
)
and
self
.
rds_enabled
:
self
.
all_rds_instances
=
config
.
getboolean
(
'ec2'
,
'all_rds_instances'
)
...
...
@@ -531,8 +553,8 @@ class Ec2Inventory(object):
''' Adds an instance to the inventory and index, as long as it is
addressable '''
# Only
want running instances unless all_instances is True
if
not
self
.
all_instances
and
instance
.
state
!=
'running'
:
# Only
return instances with desired instance states
if
instance
.
state
not
in
self
.
ec2_instance_states
:
return
# Select the best destination address
...
...
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