Skip to content

Instantly share code, notes, and snippets.

@acdha
Created August 10, 2020 22:50
Show Gist options
  • Save acdha/6a51386435b2b54dd2db9ed894b674d9 to your computer and use it in GitHub Desktop.
Save acdha/6a51386435b2b54dd2db9ed894b674d9 to your computer and use it in GitHub Desktop.
Ansible dynamic inventory using EC2 tags
---
plugin: aws_ec2
regions:
- us-east-1
filters:
instance-state-name: running
tag:Project: MyProject
tag:Environment: Development
hostnames:
- instance-id
strict: true
keyed_groups:
- prefix: tag
key: tags
- key: 'security_groups|json_query("[].group_name")'
prefix: "security_groups"
- prefix: instance_type
key: instance_type
compose:
env: tags.Environment
region: placement.region
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment