mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Add a new inventory group so you can see instances in a particular VPC
This commit is contained in:
parent
ade083a2e3
commit
d7b36dd9e7
1 changed files with 7 additions and 3 deletions
|
@ -432,7 +432,11 @@ class Ec2Inventory(object):
|
||||||
self.push(self.inventory, key_name, dest)
|
self.push(self.inventory, key_name, dest)
|
||||||
if self.nested_groups:
|
if self.nested_groups:
|
||||||
self.push_group(self.inventory, 'keys', key_name)
|
self.push_group(self.inventory, 'keys', key_name)
|
||||||
|
|
||||||
|
# Inventory: Group by VPC
|
||||||
|
if instance.vpc_id:
|
||||||
|
self.push(self.inventory, self.to_safe('vpc_id_' + instance.vpc_id), dest)
|
||||||
|
|
||||||
# Inventory: Group by security group
|
# Inventory: Group by security group
|
||||||
try:
|
try:
|
||||||
for group in instance.groups:
|
for group in instance.groups:
|
||||||
|
@ -504,13 +508,13 @@ class Ec2Inventory(object):
|
||||||
self.push(self.inventory, instance.availability_zone, dest)
|
self.push(self.inventory, instance.availability_zone, dest)
|
||||||
if self.nested_groups:
|
if self.nested_groups:
|
||||||
self.push_group(self.inventory, region, instance.availability_zone)
|
self.push_group(self.inventory, region, instance.availability_zone)
|
||||||
|
|
||||||
# Inventory: Group by instance type
|
# Inventory: Group by instance type
|
||||||
type_name = self.to_safe('type_' + instance.instance_class)
|
type_name = self.to_safe('type_' + instance.instance_class)
|
||||||
self.push(self.inventory, type_name, dest)
|
self.push(self.inventory, type_name, dest)
|
||||||
if self.nested_groups:
|
if self.nested_groups:
|
||||||
self.push_group(self.inventory, 'types', type_name)
|
self.push_group(self.inventory, 'types', type_name)
|
||||||
|
|
||||||
# Inventory: Group by security group
|
# Inventory: Group by security group
|
||||||
try:
|
try:
|
||||||
if instance.security_group:
|
if instance.security_group:
|
||||||
|
|
Loading…
Reference in a new issue