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

The `aws_ec2` inventory parses without errors but returns zero hosts

IntermediateTroubleshootingCloud, AWX, Windows and Molecule
Answer

Likely causes →

  • The wrong regions.
  • A tag filter with the wrong case (tag:env against tag:Env).
  • The wrong AWS account or profile.
  • Instances that are stopped while the filter asks for running.
  • A stale inventory cache (cache: true).

Diagnose →

aws sts get-caller-identity
aws ec2 describe-instances --region ap-south-1 --filters "Name=tag:Env,Values=prod" --query 'Reservations[].Instances[].InstanceId'
ansible-inventory -i prod.aws_ec2.yml --list -vvv | head -50

Fix → Align the filters with what the AWS CLI returns, set profile: or the environment credentials for the right account, and refresh with --flush-cache if caching is on.

Prevent → Standardise tag keys (for example Env, Role) enforced by Terraform or AWS Config, and alert when a key group comes back empty.

All Ansible questions Roadmap: Ansible

More on Cloud, AWX, Windows and Molecule