From 19ea763cd4719b239c0603bac88f73e9742a4051 Mon Sep 17 00:00:00 2001 From: Mandar Kulkarni Date: Tue, 24 Aug 2021 03:58:50 -0700 Subject: [PATCH] Adding example of using groups in aws_ec2.py module (#458) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adding example of using groups in aws_ec2.py module SUMMARY Adding a example of using groups option to add items from a specific inventory configuration to groups. Example shows use of groups to group hosts based on vpc id. Resolves #412 ISSUE TYPE Docs Pull Request COMPONENT NAME aws_ec2.py Reviewed-by: Gonéri Le Bouder Reviewed-by: Alina Buzachis Reviewed-by: Abhijeet Kasurde Reviewed-by: None --- plugins/inventory/aws_ec2.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/plugins/inventory/aws_ec2.py b/plugins/inventory/aws_ec2.py index c881943a8a5..a7244260d6e 100644 --- a/plugins/inventory/aws_ec2.py +++ b/plugins/inventory/aws_ec2.py @@ -188,6 +188,23 @@ exclude_filters: - tag:Name: - 'my_first_tag' + +# Example using groups to assign the running hosts to a group based on vpc_id +plugin: aws_ec2 +boto_profile: aws_profile +# Populate inventory with instances in these regions +regions: + - us-east-2 +filters: + # All instances with their state as `running` + instance-state-name: running +keyed_groups: + - prefix: tag + key: tags +compose: + ansible_host: public_dns_name +groups: + libvpc: vpc_id == 'vpc-####' ''' import re