# How do you use ec2 dynamic inventory with windows instances?

**URL:** <https://forum.ansible.com/t/how-do-you-use-ec2-dynamic-inventory-with-windows-instances/17676>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [March 5, 2015, 11:13am UTC](https://forum.ansible.com/t/how-do-you-use-ec2-dynamic-inventory-with-windows-instances/17676 "2015-03-05T11:13:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daniel\_Furze](https://avatars.discourse-cdn.com/v4/letter/d/6f9a4e/32.png) [@Daniel\_Furze](https://forum.ansible.com/u/Daniel_Furze)\
**Post date:** [March 5, 2015, 11:13am UTC](https://forum.ansible.com/t/how-do-you-use-ec2-dynamic-inventory-with-windows-instances/17676/1 "2015-03-05T11:13:40Z")

</div>

I’ve been playing with ansible and have everything working for managing linux instances via dynamic inventory in ec2, I have also set up windows support when using a fix hosts file.

When I try to use ec2 dynamic inventory to manage windows instances it seems to flip back to trying SSH for access.

Currently I have a simple playbook:

`

---

<div class="post-metadata">

**Author:** ![Daniel\_Furze](https://avatars.discourse-cdn.com/v4/letter/d/6f9a4e/32.png) [@Daniel\_Furze](https://forum.ansible.com/u/Daniel_Furze)\
**Post date:** [March 5, 2015, 5:25pm UTC](https://forum.ansible.com/t/how-do-you-use-ec2-dynamic-inventory-with-windows-instances/17676/2 "2015-03-05T17:25:14Z")

</div>

doh!

I solved it by creating a group\_vars file with the same name as one of my hosts tags

group\_vars\tag\_type\_iisserver.yml

---

<div class="post-metadata">

**Author:** ![Nicolas\_Landais](https://avatars.discourse-cdn.com/v4/letter/n/b9bd4f/32.png) [@Nicolas\_Landais](https://forum.ansible.com/u/Nicolas_Landais)\
**Post date:** [May 1, 2015, 9:46pm UTC](https://forum.ansible.com/t/how-do-you-use-ec2-dynamic-inventory-with-windows-instances/17676/3 "2015-05-01T21:46:42Z")

</div>

I am curious to know what your hosts file and group\_vars\tag\_type\_iisserver.yml look like. I am trying to add dynamic hosts to my static windows group in /etc/ansible/hosts using the following syntax  
[tag\_name\_xzy]

[windows:children]  
tag\_name\_xyz

as shown in the documentation and the result is : “No hosts matched” even though ec2.py does return a few hosts under the section [tag\_name\_xyz]. It’s driving me crazy. Any help is appreciated.  
Thanks

---

<div class="post-metadata">

**Author:** ![email1](https://avatars.discourse-cdn.com/v4/letter/e/f05b48/32.png) [@email1](https://forum.ansible.com/u/email1)\
**Post date:** [November 7, 2016, 4:21pm UTC](https://forum.ansible.com/t/how-do-you-use-ec2-dynamic-inventory-with-windows-instances/17676/4 "2016-11-07T16:21:07Z")

</div>

Did you ever figure this out? I’m currently getting “no hosts matched”. Any tips would be great!

---

<div class="post-metadata">

**Author:** ![Bryan\_Banks](https://avatars.discourse-cdn.com/v4/letter/b/f1d935/32.png) [@Bryan\_Banks](https://forum.ansible.com/u/Bryan_Banks)\
**Post date:** [February 9, 2017, 3:59pm UTC](https://forum.ansible.com/t/how-do-you-use-ec2-dynamic-inventory-with-windows-instances/17676/5 "2017-02-09T15:59:05Z")

</div>

To anyone who finds this and has the same problem, here’s how it works:

My playbook (myplaybook.yml)

- name: Do some stuff to windows servers

hosts: tag\_OS\_windows2012r2

gather\_facts: false

connection: local

tasks:

- name:

win\_file:

path: C:\foobar.txt

state: touch

I also created a folder / file group\_vars/tag\_OS\_windows2012r2.yml (note this file name is the same as my hosts in the playbook)

ansible\_connection: winrm

ansible\_ssh\_port: 5986

ansible\_ssh\_user: Administrator

ansible\_ssh\_pass: mypassword123

And then call your playbook with ec2.py (and AWS profiles, if you use that)

AWS\_PROFILE=main ansible-playbook -i /etc/ansible/ec2.py myplaybook.yml
