AnsiblePilot — Master Ansible Automation

AnsiblePilot is the leading resource for learning Ansible automation, DevOps, and infrastructure as code. Browse over 1,400 tutorials covering Ansible modules, playbooks, roles, collections, and real-world examples. Whether you are a beginner or an experienced engineer, our step-by-step guides help you automate Linux, Windows, cloud, containers, and network infrastructure.

Popular Topics

About Luca Berton

Luca Berton is an Ansible automation expert, author of 8 Ansible books published by Apress and Leanpub including "Ansible for VMware by Examples" and "Ansible for Kubernetes by Example", and creator of the Ansible Pilot YouTube channel. He shares practical automation knowledge through tutorials, books, and video courses to help IT professionals and DevOps engineers master infrastructure automation.

microsoft.hyperv 1.0.0 — First Certified Ansible Collection for Hyper-V

By Luca Berton · Published 2024-01-01 · Category: installation

microsoft.hyperv 1.0.0 has been certified on Ansible Automation Hub, bringing official Ansible support for Microsoft Hyper-V virtual machine management.

microsoft.hyperv 1.0.0 — First Certified Collection

microsoft.hyperv 1.0.0 has been certified and published on Ansible Automation Hub, marking the first official Ansible collection for Microsoft Hyper-V management.

See also: Ansible Windows Server 2025 Automation: WinRM, PSRP, Active Directory, IIS, Hyper-V Complete Guide

What This Means

This certified collection provides officially supported modules for managing Hyper-V virtual infrastructure through Ansible, including:

  • Virtual machine lifecycle management
  • Virtual network configuration
  • Virtual disk management
  • Hyper-V host configuration

How to Install

From Ansible Automation Hub (with a Red Hat subscription):

ansible-galaxy collection install microsoft.hyperv --server https://console.redhat.com/api/automation-hub/

Why It Matters

Hyper-V is widely used in enterprise Windows environments. Having an officially certified collection means:

  • Tested and validated against Ansible Automation Platform
  • Supported by Microsoft as the collection maintainer
  • Consistent lifecycle aligned with Ansible certification requirements
  • Enterprise-ready for production use cases

Certified Collections This Week

Other collections also updated on Automation Hub this week:

CollectionVersion
chocolatey.chocolatey1.6.0
cisco.intersight2.16.0
cisco.meraki2.23.1
cyberark.isp1.0.7
cyberark.pas1.0.39
ibm.power_hmc1.15.0
microsoft.hyperv1.0.0
netscaler.adc2.16.0
redhat.amq_streams1.0.1
redhat.artifact_signer1.3.3
redhat.jbcs1.1.4
redhat.jws2.1.2
redhat.openshift_virtualization2.2.4
redhat.runtimes_common1.2.3
redhat.satellite_operations4.0.0
redhat.sso2.0.1

Resources

See also: Ansible on Hyper-V on Windows Server 2025 Automation Complete Guide

Installing the Collection

ansible-galaxy collection install microsoft.hyperv

Managing Hyper-V VMs with Ansible

- name: Manage Hyper-V virtual machines
  hosts: hyperv_hosts
  tasks:
    - name: Create a new VM
      microsoft.hyperv.win_hyperv_guest:
        name: test-vm
        generation: 2
        memory: 4GB
        cpu_count: 2
        state: present

    - name: Attach virtual disk
      microsoft.hyperv.win_hyperv_guest:
        name: test-vm
        hard_drives:
          - path: 'C:\VMs\test-vm\disk.vhdx'
            size: 50GB

    - name: Start VM
      microsoft.hyperv.win_hyperv_guest:
        name: test-vm
        state: running

    - name: Configure VM network adapter
      microsoft.hyperv.win_hyperv_guest:
        name: test-vm
        network_adapters:
          - name: "Default Switch"
            switch_name: "Default Switch"

See also: Ansible on Windows Server 2022 Automation: WinRM, Active Directory, IIS, Hyper-V Complete Guide

Hyper-V Host Configuration

- name: Configure Hyper-V host
  hosts: hyperv_hosts
  tasks:
    - name: Ensure Hyper-V feature is enabled
      ansible.windows.win_feature:
        name: Hyper-V
        include_management_tools: true
        state: present
      register: hyperv_install

    - name: Reboot if needed
      ansible.windows.win_reboot:
      when: hyperv_install.reboot_required

    - name: Create virtual switch
      ansible.windows.win_shell: |
        New-VMSwitch -Name "Production" -NetAdapterName "Ethernet" -AllowManagementOS $true
      register: result
      changed_when: "'already exists' not in result.stderr"
      failed_when: false

FAQ

What is the microsoft.hyperv collection?

It is the first certified Ansible collection for managing Microsoft Hyper-V infrastructure. It provides modules for creating, configuring, and managing VMs, virtual switches, and virtual hard disks.

Do I need WinRM configured on the Hyper-V host?

Yes. Ansible manages Windows hosts via WinRM. Enable WinRM on the Hyper-V host and configure ansible_connection=winrm in your inventory.

Can I manage Hyper-V on Windows Server and Windows 10/11?

Yes. The collection works with Hyper-V on both Windows Server (2016, 2019, 2022) and Windows 10/11 Pro/Enterprise with the Hyper-V feature enabled.

Category: installation

Browse all Ansible tutorials · AnsiblePilot Home