mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
[cloud] Add group_by_instance_state to EC2 Dynamic Inventory (#20430)
This commit is contained in:
parent
86ed4b116c
commit
cf424f0413
2 changed files with 9 additions and 0 deletions
|
@ -128,6 +128,7 @@ group_by_availability_zone = True
|
||||||
group_by_aws_account = False
|
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_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
|
||||||
|
|
|
@ -414,6 +414,7 @@ class Ec2Inventory(object):
|
||||||
'group_by_availability_zone',
|
'group_by_availability_zone',
|
||||||
'group_by_ami_id',
|
'group_by_ami_id',
|
||||||
'group_by_instance_type',
|
'group_by_instance_type',
|
||||||
|
'group_by_instance_state',
|
||||||
'group_by_key_pair',
|
'group_by_key_pair',
|
||||||
'group_by_vpc_id',
|
'group_by_vpc_id',
|
||||||
'group_by_security_group',
|
'group_by_security_group',
|
||||||
|
@ -859,6 +860,13 @@ class Ec2Inventory(object):
|
||||||
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 instance state
|
||||||
|
if self.group_by_instance_state:
|
||||||
|
state_name = self.to_safe('instance_state_' + instance.state)
|
||||||
|
self.push(self.inventory, state_name, hostname)
|
||||||
|
if self.nested_groups:
|
||||||
|
self.push_group(self.inventory, 'instance_states', state_name)
|
||||||
|
|
||||||
# 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