# Specifying WIndows systems in a mixed host environment

**URL:** <https://forum.ansible.com/t/specifying-windows-systems-in-a-mixed-host-environment/28771>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [October 12, 2018, 12:17am UTC](https://forum.ansible.com/t/specifying-windows-systems-in-a-mixed-host-environment/28771 "2018-10-12T00:17:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hunter\_Tom](https://avatars.discourse-cdn.com/v4/letter/h/f4b2a3/32.png) [@Hunter\_Tom](https://forum.ansible.com/u/Hunter_Tom)\
**Post date:** [October 12, 2018, 12:17am UTC](https://forum.ansible.com/t/specifying-windows-systems-in-a-mixed-host-environment/28771/1 "2018-10-12T00:17:07Z")

</div>

Hello All:  
Please help!

Problem -

I have a hosts file separated out with different branches of an organization as such:

[branch01]  
server01  
server02  
server03  
[branch02]  
server04  
server05  
…etc

The problem is that if server01 and server05 are windows, how do I specify to use WinRM?

I’ve tried the following:

- Using ‘register:’ in [https://www.reddit.com/r/ansible/comments/67q35z/is\_it\_possible\_for\_an\_ansible\_playbook\_to/](https://www.reddit.com/r/ansible/comments/67q35z/is_it_possible_for_an_ansible_playbook_to/) [did not work]

- Setting [branch:vars] to winrm (and tried to use gather\_facts to specify linux instead) [did not work]

- Gather\_facts: True. Then using when: ansible\_os\_family == windows. [fails because it uses ports 22 rather than 5986  
Is there a way to dynamically switch from SSH to WINRM based on the way I have my hosts set up?

---

<div class="post-metadata">

**Author:** ![jborean](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jborean/32/1525_2.png) [@jborean](https://forum.ansible.com/u/jborean)\
**Post date:** [October 12, 2018, 4:39am UTC](https://forum.ansible.com/t/specifying-windows-systems-in-a-mixed-host-environment/28771/2 "2018-10-12T04:39:06Z")

</div>

Easiest way is to create a Windows group, define the connection plugin in that group, and finally add your Windows hosts as children of that group;

`  
[windows:children]  
server01  
server03  
branch02  
…

[windows:vars]  
ansible\_connection=winrm

`

You can add some more values to configure WinRM if you wish but by default you at least need to tell Ansible to use the winrm connection plugin.

---

<div class="post-metadata">

**Author:** ![Hunter\_Tom](https://avatars.discourse-cdn.com/v4/letter/h/f4b2a3/32.png) [@Hunter\_Tom](https://forum.ansible.com/u/Hunter_Tom)\
**Post date:** [October 12, 2018, 1:26pm UTC](https://forum.ansible.com/t/specifying-windows-systems-in-a-mixed-host-environment/28771/3 "2018-10-12T13:26:23Z")

</div>

Okay, thanks. I was trying to ensure against putting the host name twice to ensure against confusion. I guess I will separate the branches futher by [branch01\_linux] and [branch01\_windows]…ect. Thanks for the clarification. I just wish I could use logic (‘if unable to connect ssh then try winrm’) against my hosts
