diff --git a/contrib/inventory/ec2.ini b/contrib/inventory/ec2.ini index e11a69cc16..ab1ad6222d 100644 --- a/contrib/inventory/ec2.ini +++ b/contrib/inventory/ec2.ini @@ -135,6 +135,7 @@ group_by_aws_account = False group_by_ami_id = True group_by_instance_type = True group_by_instance_state = False +group_by_platform = True group_by_key_pair = True group_by_vpc_id = True group_by_security_group = True diff --git a/contrib/inventory/ec2.py b/contrib/inventory/ec2.py index 16f52890b2..060c5e6424 100755 --- a/contrib/inventory/ec2.py +++ b/contrib/inventory/ec2.py @@ -930,6 +930,16 @@ class Ec2Inventory(object): if self.nested_groups: self.push_group(self.inventory, 'instance_states', state_name) + # Inventory: Group by platform + if self.group_by_platform: + if instance.platform: + platform = self.to_safe('platform_' + instance.platform) + else: + platform = self.to_safe('platform_undefined') + self.push(self.inventory, platform, hostname) + if self.nested_groups: + self.push_group(self.inventory, 'platforms', platform) + # Inventory: Group by key pair if self.group_by_key_pair and instance.key_name: key_name = self.to_safe('key_' + instance.key_name)