Skip to content

Commit

Permalink
Adding example of using groups in aws_ec2.py module (ansible-collecti…
Browse files Browse the repository at this point in the history
…ons#458)

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 ansible-collections#412

ISSUE TYPE

Docs Pull Request

COMPONENT NAME

aws_ec2.py

Reviewed-by: Gonéri Le Bouder <[email protected]>
Reviewed-by: Alina Buzachis <None>
Reviewed-by: Abhijeet Kasurde <None>
Reviewed-by: None <None>
  • Loading branch information
mandar242 authored Aug 24, 2021
1 parent 6c767b1 commit 19ea763
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions plugins/inventory/aws_ec2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 19ea763

Please sign in to comment.