You must apply a change to hosts in two regions with different SSH keys.
IntermediateScenarioInventory and Targeting
Answer
Situation read → Credentials are per group.
What I'd do → Group per region and set the key in group_vars.
# group_vars/eu.yml
ansible_ssh_private_key_file: ~/.ssh/eu-prod.pem
# group_vars/us.yml
ansible_ssh_private_key_file: ~/.ssh/us-prod.pem
Why → The play stays identical; only the connection details vary by group.
Interview tip → In AWX, use separate machine credentials per inventory source instead of file paths.
More on Inventory and Targeting
You are handed a fresh Ansible project and 10 servers. How do you make sure Ansible can reach all of them before writing any playbook?BeginnerYour team keeps prod and staging hosts in one inventory file and someone ran a playbook on prod by mistake. How do you prevent it?IntermediateYou need to run a playbook on only the web servers in Mumbai that are not in the canary group. How?BeginnerServers are autoscaled in AWS and IPs change daily. How do you keep the inventory accurate?IntermediateA host is reachable by SSH on port 2222 with a different user from all others. How do you model that?BeginnerYou must configure servers in a private subnet that is only reachable through a bastion.Intermediate