Use dynamic inventory with windows ec2

43 views
Skip to first unread message

chall...@gmail.com

unread,
Nov 13, 2016, 8:30:36 PM11/13/16
to Ansible Project
Can any one suggest me with best way for using dynamic inventory for ec2 windows.
Usually for linux ec2.....i have a play which goes like

1) creates a ec2 instance  ---first play
2) refresh dynamic inventory ---2nd play
3) connect to linux instance --3rd play

but when i do the same thing with windows ec2...ansible is trying to ssh into the windows host and failing..

can any one post a sample play that i can use to create ec2 windows,,,refresh dynamic inventory and connect and configure the windows in the same playbook without having to create a static inventory for windows.

J Hawkesworth

unread,
Nov 14, 2016, 5:40:27 AM11/14/16
to Ansible Project
I don't have any examples but I think you could have a static group_vars/windows.yml file that sets the windows connection settings and then add_host the windows instance(s) to your pre-existing static windows group.

Hope this helps,

Jon

Matt Davis

unread,
Nov 14, 2016, 11:47:30 AM11/14/16
to Ansible Project
Yep, that's exactly what we tell folks to do. You can also use a conditional meta: refresh_inventory with the same technique (and map the tag-based groups into "human-readable" group names in the static inventory) when the task returns new hosts created instead of the add_host. That way you don't have to worry about dynamically mapping groups in your playbook- you can keep it all abstracted in the inventory. Functionally about the same...

-Matt

Bryan Banks

unread,
Feb 7, 2017, 5:39:41 PM2/7/17
to Ansible Project
Hi, I'm sorry to bring up an old thread but could you show an example of how you would go about doing this? My goal is to use dynamic inventory with Windows EC2 instances (works fine with linux)
Reply all
Reply to author
Forward
0 new messages