Provision Hyper-V virtual machines thru Ansible

Hello All,

I am newbie to Ansible.

Can someone pls point me to resources or post some playbook code that deploys VM’s on a Hyper-V 2012 or 2016 server ? Alternatively, lets say if i have a golden image of a VM created ( in *.vhd or *.vhdx format), how can i deploy this image to multiple hosts using Ansible?
I have looked online and see there is stuff for Vmware but couldnt find much help for Hyper-V

thanks

Hi Neeraj ,

As of now , there is no ansible native modules available to support this.
steps involved to get this done.

  1. create one windows host
  2. connect to this host using ansible and invoke powerhsell module for deploying resources in hyper-v
    https://docs.microsoft.com/en-us/powershell/module/hyper-v/new-vm?view=win10-ps

Thanks Jaya. But how do you run those hyper-v cmdlets using playbooks ? Do i need to use win_shell module ?