Skip to content

gocallag/hyperv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ansible Collection - gocallag.hyperv

License

gocallag.hyperv Collection

This collection provides a range of modules for managing Hyper-V hosts and VM's etc that run on those hosts.

Note: This collection is still in active development. There may be unidentified issues and various variables may change as development continues.

Requirements

Ansible

  • This collection is developed and tested with maintained versions of Ansible core (above 2.12).

Installation

This collection can be installed via either Ansible Galaxy (the Ansible community marketplace) at (https://galaxy.ansible.com/gocallag/hyper-v) or by cloning this repo.

Ansible Galaxy

To install the latest stable release of the collection on your system, use:

ansible-galaxy collection install gocallag.hyperv

Alternatively, if you have already installed the role, you can update the role to the latest release by using:

ansible-galaxy collection install -f gocallag.hyperv

As the collection provides a range of modules you will need to include them as appropriate in your playbook:

- name: Create VM
  gocallag.hyperv.vm:
    name: TEST01

Platforms

This collection has been tested against the following Hyper-V configurations

Windows Server:
  - 2025 (Preview)
  - 2022

Example Playbooks

Working functional playbook examples can be found in the molecule/ folder in the following files:

Name Description
create switch Create a Hyper-V vswitch
delete switch Delete a Hyper-V vswitch
get switch info Get information about a Hyper-V vswitch
create vm Create a Hyper-V VM
delete vm Delete a Hyper-V VM
get vm info Get information about a Hyper-V VM
power on/off vm Power On/Off VM

Tesing with Molecule

In order to test locally using molecule you will need a target vm running Windows server with Hyper-V enabled/working.

You will need to set the following environment variables

export INSTANCE_TESTHOST=<name/ip of your test host>
export INSTANCE_TESTHOST_USERID=<userid, typically Administrator>
export INSTANCE_TESTHOST_PASSWORD=<password for the above userid>

Then it's a simple case of

cd hyperv
molecule test -s vm_disk    # or similar

License

Apache License, Version 2.0

Author Information

Geoff O'Callaghan