Show a minimal `aws_ec2` dynamic inventory configuration.
IntermediateConceptInventory
Answer
# inventory/aws_ec2.yml
plugin: amazon.aws.aws_ec2
regions:
- ap-south-1
filters:
instance-state-name: running
tag:Env: prod
compose:
ansible_host: private_ip_address
ansible-galaxy collection install amazon.aws
pip install boto3 botocore
ansible-inventory -i inventory/aws_ec2.yml --graph
Credentials come from the normal AWS chain (environment variables, shared profile, or an instance role). The file name must end in aws_ec2.yml or aws_ec2.yaml, or the plugin refuses it.
More on Inventory
What is an inventory and why does Ansible need one?BeginnerWhat are the INI and YAML inventory formats and how do they differ?BeginnerHow do you create groups of groups?BeginnerExplain host patterns: `:`, `:&`, `:!` and wildcards.IntermediateWhich connection variables can you set per host in inventory?BeginnerWhat are `group_vars` and `host_vars` directories?Intermediate