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
caef3a0d
Commit
caef3a0d
authored
Jul 09, 2014
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #8010 from cchurch/ec2_all_instances
Add option to return all EC2/RDS instances regardless of state.
parents
2efbdd24
7f27c56a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
4 deletions
+22
-4
plugins/inventory/ec2.ini
+8
-0
plugins/inventory/ec2.py
+14
-4
No files found.
plugins/inventory/ec2.ini
View file @
caef3a0d
...
...
@@ -42,6 +42,14 @@ route53 = False
# 'route53_excluded_zones' as a comma-separated list.
# route53_excluded_zones = samplezone1.com, samplezone2.com
# By default, only EC2 instances in the 'running' state are returned. Set
# 'all_instances' to True to return all instances regardless of state.
all_instances
=
False
# 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
# API calls to EC2 are slow. For this reason, we cache the results of an API
# call. Set this to the path you want cache files to be written to. Two files
# will be written to this directory:
...
...
plugins/inventory/ec2.py
View file @
caef3a0d
...
...
@@ -222,6 +222,16 @@ class Ec2Inventory(object):
self
.
route53_excluded_zones
.
extend
(
config
.
get
(
'ec2'
,
'route53_excluded_zones'
,
''
)
.
split
(
','
))
# Return all EC2/RDS instances
if
config
.
has_option
(
'ec2'
,
'all_instances'
):
self
.
all_instances
=
config
.
getboolean
(
'ec2'
,
'all_instances'
)
else
:
self
.
all_instances
=
False
if
config
.
has_option
(
'ec2'
,
'all_rds_instances'
):
self
.
all_rds_instances
=
config
.
getboolean
(
'ec2'
,
'all_rds_instances'
)
else
:
self
.
all_rds_instances
=
False
# Cache related
cache_dir
=
os
.
path
.
expanduser
(
config
.
get
(
'ec2'
,
'cache_path'
))
if
not
os
.
path
.
exists
(
cache_dir
):
...
...
@@ -326,8 +336,8 @@ class Ec2Inventory(object):
''' Adds an instance to the inventory and index, as long as it is
addressable '''
# Only want running instances
if
instance
.
state
!=
'running'
:
# Only want running instances
unless all_instances is True
if
not
self
.
all_instances
and
instance
.
state
!=
'running'
:
return
# Select the best destination address
...
...
@@ -390,8 +400,8 @@ class Ec2Inventory(object):
''' Adds an RDS instance to the inventory and index, as long as it is
addressable '''
# Only want available instances
if
instance
.
status
!=
'available'
:
# Only want available instances
unless all_rds_instances is True
if
not
self
.
all_rds_instances
and
instance
.
status
!=
'available'
:
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