Interview Prep/Ansible/Cloud, AWX, Windows and Molecule

`[WARNING]: * Failed to parse inventory/aws.yml with auto plugin: inventory source 'inventory/aws.yml' could not be verified by inventory plugin 'amazon.aws.aws_ec2'`

IntermediateTroubleshootingCloud, AWX, Windows and Molecule
Answer

Likely causes → The aws_ec2 plugin only accepts files whose names end in aws_ec2.yml or aws_ec2.yaml. It can also fail if the collection is not installed, or if enable_plugins in ansible.cfg excludes auto and amazon.aws.aws_ec2.

Fix → Rename the file to inventory/prod.aws_ec2.yml:

plugin: amazon.aws.aws_ec2
regions: [ap-south-1]
filters:
  instance-state-name: running
  "tag:Env": prod

Test it with ansible-inventory -i inventory/prod.aws_ec2.yml --graph.

Prevent → Use the naming convention <env>.aws_ec2.yml, and check the inventory with ansible-inventory --graph in CI.

All Ansible questions Roadmap: Ansible

More on Cloud, AWX, Windows and Molecule