Use dynamic inventory with windows ec2

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.

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

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

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)