You manage Windows and Linux servers from one controller. How do you structure the inventory?
IntermediateScenarioInventory and Targeting
Answer
Situation read → Two connection types, two sets of modules.
What I'd do → Separate groups with connection variables in group_vars.
# group_vars/windows.yml
ansible_connection: winrm
ansible_winrm_transport: ntlm
ansible_winrm_server_cert_validation: ignore
ansible_port: 5986
# group_vars/linux.yml
ansible_connection: ssh
Use ansible.windows.* modules for the Windows group, and ansible_connection: psrp or SSH if WinRM is not allowed.
Why → Keeping connection settings at group level lets playbooks stay platform-neutral where possible.
Interview tip → Install pywinrm on the controller and mention that certificate validation should not be ignored outside labs.
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