mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Add option to group ec2 instances by platform. (#27848)
All credits to https://github.com/felipecvo See PR: https://github.com/ansible/ansible/pull/14246
This commit is contained in:
parent
1fe14da226
commit
ce5e4dfc38
2 changed files with 11 additions and 0 deletions
|
@ -135,6 +135,7 @@ group_by_aws_account = False
|
||||||
group_by_ami_id = True
|
group_by_ami_id = True
|
||||||
group_by_instance_type = True
|
group_by_instance_type = True
|
||||||
group_by_instance_state = False
|
group_by_instance_state = False
|
||||||
|
group_by_platform = True
|
||||||
group_by_key_pair = True
|
group_by_key_pair = True
|
||||||
group_by_vpc_id = True
|
group_by_vpc_id = True
|
||||||
group_by_security_group = True
|
group_by_security_group = True
|
||||||
|
|
|
@ -930,6 +930,16 @@ class Ec2Inventory(object):
|
||||||
if self.nested_groups:
|
if self.nested_groups:
|
||||||
self.push_group(self.inventory, 'instance_states', state_name)
|
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
|
# Inventory: Group by key pair
|
||||||
if self.group_by_key_pair and instance.key_name:
|
if self.group_by_key_pair and instance.key_name:
|
||||||
key_name = self.to_safe('key_' + instance.key_name)
|
key_name = self.to_safe('key_' + instance.key_name)
|
||||||
|
|
Loading…
Reference in a new issue