Skip to content

Commit

Permalink
Add option to group ec2 instances by platform. (ansible#27848)
Browse files Browse the repository at this point in the history
  • Loading branch information
default50 authored and calfonso committed Aug 7, 2017
1 parent 1fe14da commit ce5e4df
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions contrib/inventory/ec2.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions contrib/inventory/ec2.py
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,16 @@ def add_instance(self, instance, region):
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)
Expand Down

0 comments on commit ce5e4df

Please sign in to comment.