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
2a242a0e
Commit
2a242a0e
authored
Jun 14, 2015
by
Victor Schröder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Creates add_elasticache_node method in ec2.py
parent
98a55319
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
99 additions
and
0 deletions
+99
-0
plugins/inventory/ec2.py
+99
-0
No files found.
plugins/inventory/ec2.py
View file @
2a242a0e
...
...
@@ -781,6 +781,105 @@ class Ec2Inventory(object):
self
.
inventory
[
"_meta"
][
"hostvars"
][
dest
]
=
host_info
# Add the nodes
for
node
in
cluster
[
'CacheNodes'
]:
self
.
add_elasticache_node
(
node
,
cluster
,
region
)
def
add_elasticache_node
(
self
,
node
,
cluster
,
region
):
''' Adds an ElastiCache node to the inventory and index, as long as
it is addressable '''
# Only want available nodes unless all_elasticache_nodes is True
if
not
self
.
all_elasticache_nodes
and
node
[
'CacheNodeStatus'
]
!=
'available'
:
return
# Select the best destination address
dest
=
node
[
'Endpoint'
][
'Address'
]
if
not
dest
:
# Skip nodes we cannot address (e.g. private VPC subnet)
return
node_id
=
self
.
to_safe
(
cluster
[
'CacheClusterId'
]
+
'_'
+
node
[
'CacheNodeId'
])
# Add to index
self
.
index
[
dest
]
=
[
region
,
node_id
]
# Inventory: Group by node ID (always a group of 1)
if
self
.
group_by_instance_id
:
self
.
inventory
[
node_id
]
=
[
dest
]
if
self
.
nested_groups
:
self
.
push_group
(
self
.
inventory
,
'instances'
,
node_id
)
# Inventory: Group by region
if
self
.
group_by_region
:
self
.
push
(
self
.
inventory
,
region
,
dest
)
if
self
.
nested_groups
:
self
.
push_group
(
self
.
inventory
,
'regions'
,
region
)
# Inventory: Group by availability zone
if
self
.
group_by_availability_zone
:
self
.
push
(
self
.
inventory
,
cluster
[
'PreferredAvailabilityZone'
],
dest
)
if
self
.
nested_groups
:
if
self
.
group_by_region
:
self
.
push_group
(
self
.
inventory
,
region
,
cluster
[
'PreferredAvailabilityZone'
])
self
.
push_group
(
self
.
inventory
,
'zones'
,
cluster
[
'PreferredAvailabilityZone'
])
# Inventory: Group by node type
if
self
.
group_by_instance_type
:
type_name
=
self
.
to_safe
(
'type_'
+
cluster
[
'CacheNodeType'
])
self
.
push
(
self
.
inventory
,
type_name
,
dest
)
if
self
.
nested_groups
:
self
.
push_group
(
self
.
inventory
,
'types'
,
type_name
)
# Inventory: Group by VPC
# if self.group_by_vpc_id and instance.subnet_group and instance.subnet_group.vpc_id:
# vpc_id_name = self.to_safe('vpc_id_' + instance.subnet_group.vpc_id)
# self.push(self.inventory, vpc_id_name, dest)
# if self.nested_groups:
# self.push_group(self.inventory, 'vpcs', vpc_id_name)
# Inventory: Group by security group
if
self
.
group_by_security_group
:
if
'SecurityGroups'
in
cluster
:
for
security_group
in
cluster
[
'SecurityGroups'
]:
key
=
self
.
to_safe
(
"security_group_"
+
security_group
[
'SecurityGroupId'
])
self
.
push
(
self
.
inventory
,
key
,
dest
)
if
self
.
nested_groups
:
self
.
push_group
(
self
.
inventory
,
'security_groups'
,
key
)
# Inventory: Group by engine
if
self
.
group_by_elasticache_engine
:
self
.
push
(
self
.
inventory
,
self
.
to_safe
(
"elasticache_"
+
cluster
[
'Engine'
]),
dest
)
if
self
.
nested_groups
:
self
.
push_group
(
self
.
inventory
,
'elasticache_engines'
,
self
.
to_safe
(
"elasticache_"
+
cluster
[
'Engine'
]))
# Inventory: Group by parameter group
# if self.group_by_elasticache_parameter_group:
# self.push(self.inventory, self.to_safe("elasticache_parameter_group_" + cluster['CacheParameterGroup']['CacheParameterGroupName']), dest)
# if self.nested_groups:
# self.push_group(self.inventory, 'elasticache_parameter_groups', self.to_safe("elasticache_parameter_group_" + cluster['CacheParameterGroup']['CacheParameterGroupName']))
# Inventory: Group by replication group
# if self.group_by_elasticache_replication_group and 'ReplicationGroupId' in cluster and cluster['ReplicationGroupId']:
# self.push(self.inventory, self.to_safe("elasticache_replication_group_" + cluster['ReplicationGroupId']), dest)
# if self.nested_groups:
# self.push_group(self.inventory, 'elasticache_replication_groups', self.to_safe("elasticache_" + cluster['ReplicationGroupId']))
# Inventory: Group by ElastiCache Cluster
if
self
.
group_by_elasticache_cluster
:
self
.
push
(
self
.
inventory
,
self
.
to_safe
(
"elasticache_cluster_"
+
cluster
[
'CacheClusterId'
]),
dest
)
# Global Tag: all ElastiCache nodes
self
.
push
(
self
.
inventory
,
'elasticache_nodes'
,
dest
)
host_info
=
self
.
get_host_info_dict_from_describe_dict
(
node
)
if
dest
in
self
.
inventory
[
"_meta"
][
"hostvars"
]:
self
.
inventory
[
"_meta"
][
"hostvars"
][
dest
]
.
update
(
host_info
)
else
:
self
.
inventory
[
"_meta"
][
"hostvars"
][
dest
]
=
host_info
def
get_route53_records
(
self
):
''' Get and store the map of resource records to domain names that
point to them. '''
...
...
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