From d7b36dd9e7652755951579788ae226bb98ee78a4 Mon Sep 17 00:00:00 2001 From: Dan Jenkins Date: Tue, 25 Mar 2014 09:54:04 +0000 Subject: [PATCH] Add a new inventory group so you can see instances in a particular VPC --- plugins/inventory/ec2.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/plugins/inventory/ec2.py b/plugins/inventory/ec2.py index 9d2dec38d33..37b2c5b05ca 100755 --- a/plugins/inventory/ec2.py +++ b/plugins/inventory/ec2.py @@ -432,7 +432,11 @@ class Ec2Inventory(object): self.push(self.inventory, key_name, dest) if self.nested_groups: 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 try: for group in instance.groups: @@ -504,13 +508,13 @@ class Ec2Inventory(object): self.push(self.inventory, instance.availability_zone, dest) if self.nested_groups: self.push_group(self.inventory, region, instance.availability_zone) - + # Inventory: Group by instance type type_name = self.to_safe('type_' + instance.instance_class) self.push(self.inventory, type_name, dest) if self.nested_groups: self.push_group(self.inventory, 'types', type_name) - + # Inventory: Group by security group try: if instance.security_group: