Interview Prep/Ansible/Inventory and Targeting

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.

All Ansible questions Roadmap: Ansible

More on Inventory and Targeting