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
364ad44d
Commit
364ad44d
authored
Dec 05, 2013
by
jctanner
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5188 from Multifarious/devel
ec2 inventory now include Ansible 1.3 style _meta data each host.
parents
5e336d7c
94d60b53
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
19 deletions
+23
-19
plugins/inventory/ec2.py
+23
-19
No files found.
plugins/inventory/ec2.py
View file @
364ad44d
...
...
@@ -136,7 +136,7 @@ class Ec2Inventory(object):
# Inventory grouped by instance IDs, tags, security groups, regions,
# and availability zones
self
.
inventory
=
{}
self
.
inventory
=
{
"_meta"
:
{
"hostvars"
:
{}}
}
# Index of hostname (address) to instance ID
self
.
index
=
{}
...
...
@@ -376,6 +376,8 @@ class Ec2Inventory(object):
# Global Tag: tag all EC2 instances
self
.
push
(
self
.
inventory
,
'ec2'
,
dest
)
self
.
inventory
[
"_meta"
][
"hostvars"
][
dest
]
=
self
.
get_host_info_dict_from_instance
(
instance
)
def
add_rds_instance
(
self
,
instance
,
region
):
''' Adds an RDS instance to the inventory and index, as long as it is
...
...
@@ -479,23 +481,7 @@ class Ec2Inventory(object):
return
list
(
name_list
)
def
get_host_info
(
self
):
''' Get variables about a specific host '''
if
len
(
self
.
index
)
==
0
:
# Need to load index from cache
self
.
load_index_from_cache
()
if
not
self
.
args
.
host
in
self
.
index
:
# try updating the cache
self
.
do_api_calls_update_cache
()
if
not
self
.
args
.
host
in
self
.
index
:
# host migh not exist anymore
return
self
.
json_format_dict
({},
True
)
(
region
,
instance_id
)
=
self
.
index
[
self
.
args
.
host
]
instance
=
self
.
get_instance
(
region
,
instance_id
)
def
get_host_info_dict_from_instance
(
self
,
instance
):
instance_vars
=
{}
for
key
in
vars
(
instance
):
value
=
getattr
(
instance
,
key
)
...
...
@@ -536,8 +522,26 @@ class Ec2Inventory(object):
#print type(value)
#print value
return
self
.
json_format_dict
(
instance_vars
,
True
)
return
instance_vars
def
get_host_info
(
self
):
''' Get variables about a specific host '''
if
len
(
self
.
index
)
==
0
:
# Need to load index from cache
self
.
load_index_from_cache
()
if
not
self
.
args
.
host
in
self
.
index
:
# try updating the cache
self
.
do_api_calls_update_cache
()
if
not
self
.
args
.
host
in
self
.
index
:
# host migh not exist anymore
return
self
.
json_format_dict
({},
True
)
(
region
,
instance_id
)
=
self
.
index
[
self
.
args
.
host
]
instance
=
self
.
get_instance
(
region
,
instance_id
)
return
self
.
json_format_dict
(
self
.
get_host_info_dict_from_instance
(
instance
),
True
)
def
push
(
self
,
my_dict
,
key
,
element
):
''' Pushed an element onto an array that may not have been defined in
...
...
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