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

Dynamic inventory finds the instances, but every host is `UNREACHABLE`

IntermediateTroubleshootingCloud, AWX, Windows and Molecule
Answer

Likely causes → By default, the plugin names hosts by public DNS. Private-subnet instances have no public DNS, or the controller cannot route to it. Ansible then tries to connect to an address that does not work.

Diagnose → ansible-inventory -i prod.aws_ec2.yml --host <name> | jq '.ansible_host, .private_ip_address, .public_dns_name'

Fix →

hostnames:
  - tag:Name
  - private-ip-address
compose:
  ansible_host: private_ip_address

Run from inside the VPC, or go through a bastion (ProxyJump) or SSM.

Prevent → Use readable names for hosts (tag:Name) and keep connection addresses in compose.

All Ansible questions Roadmap: Ansible

More on Cloud, AWX, Windows and Molecule