# windows dynamic inventory

**URL:** <https://forum.ansible.com/t/windows-dynamic-inventory/32241>\
**Category:** Ansible Project\
**Tags:** azure, windows, aws\
**Created:** [February 15, 2020, 6:57am UTC](https://forum.ansible.com/t/windows-dynamic-inventory/32241 "2020-02-15T06:57:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrew\_Morgan](https://avatars.discourse-cdn.com/v4/letter/a/50afbb/32.png) [@Andrew\_Morgan](https://forum.ansible.com/u/Andrew_Morgan)\
**Post date:** [February 15, 2020, 6:57am UTC](https://forum.ansible.com/t/windows-dynamic-inventory/32241/1 "2020-02-15T06:57:52Z")

</div>

Hello Guys,

I am working in an azure environment and after research I am in need of some help. I am unable to find anywhere how to setup and use correctly azure plugin for dynamic inventory. Is this possible? Has anyone done it? (I have used this inventory type with Ansible in aws with linux servers). From what I understand from the documentation and current setup:

1)The environment is using ansible to run playbooks on all windows env  
2)They are using static hosting with group/host.yml file for credentials

My setup

`

plugin: azure\_rm

include\_vm\_resource\_groups:

- sittst\_APP\_RG

auth\_source: auto

`

And I can run a ping command and get a valid denied to show the command is working (finding the servers)

`

fatal: [sittst-BATW-0\_51db]: UNREACHABLE! =\> {  
“changed”: false,  
“unreachable”: true  
}

MSG:

Failed to connect to the host via ssh: ssh: connect to host 10.176.96.130 port 22: Connection timed out

fatal: [sittst-BATD-0\_b136]: UNREACHABLE! =\> {  
“changed”: false,  
“unreachable”: true  
}

`

My issue now is how do I get it to connect to the windows servers

`

telnet 10.176.96.130 5985  
Trying 10.176.96.130…  
Connected to 10.176.96.130.  
Escape character is ‘^]’.

`

Does this mean that in my config I will have to have something like this

`

```auto

plugin: azure_rm

include_vm_resource_groups:
- sittst_APP_RG

auth_source: auto

conditional_groups:
  all_the_hosts: true
  sittst-servers: "'sittst' in name"

```

`

and the create a file in **group\_vars/sittst.yaml**

`

---

<div class="post-metadata">

**Author:** ![Andrew\_Morgan](https://avatars.discourse-cdn.com/v4/letter/a/50afbb/32.png) [@Andrew\_Morgan](https://forum.ansible.com/u/Andrew_Morgan)\
**Post date:** [February 17, 2020, 1:20am UTC](https://forum.ansible.com/t/windows-dynamic-inventory/32241/2 "2020-02-17T01:20:27Z")

</div>

Any help?

---

<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:** [February 17, 2020, 2:15am UTC](https://forum.ansible.com/t/windows-dynamic-inventory/32241/3 "2020-02-17T02:15:07Z")

</div>

Based on your output Ansible is still trying to connect over SSH with port 22. Your group vars are not applying to the host so it’s just using the defaults (SSH port 22).

---

<div class="post-metadata">

**Author:** ![Andrew\_Morgan](https://avatars.discourse-cdn.com/v4/letter/a/50afbb/32.png) [@Andrew\_Morgan](https://forum.ansible.com/u/Andrew_Morgan)\
**Post date:** [March 2, 2020, 4:03am UTC](https://forum.ansible.com/t/windows-dynamic-inventory/32241/4 "2020-03-02T04:03:10Z")

</div>

Thank you, so am I doing something wrong? Is there any documentation on this?

---

<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:** [March 2, 2020, 5:11am UTC](https://forum.ansible.com/t/windows-dynamic-inventory/32241/5 "2020-03-02T05:11:46Z")

</div>

I haven’t worked with the Azure dynamic inventory so I could be wrong but my guess is that with the lines

` `

```auto
conditional_groups:
  all_the_hosts: true
  sittst-servers: "'sittst' in name"

```

` `

You are creating a group called sittst-server which contains your host. You then have a file ‘group\_vars/sittst.yaml’ which will only apply to hosts in the ‘sittst’ group and not ‘sittst-server’. The ‘group: sittst-servers’ entry in your group\_vars file does not assign a group name to the hosts but rather just sets the group var which is nothing special. Either chang ethe filename to sittst-server.yaml or change the group name in conditional\_groups to sittst.
