Forge Home

libvirt

Puppet module to install libvirt and create virtual domain configuration

50,185 downloads

96 latest version

5.0 quality score

We run a couple of automated
scans to help you access a
module's quality. Each module is
given a score based on how well
the author has formatted their
code and documentation and
modules are also checked for
malware using VirusTotal.

Please note, the information below
is for guidance only and neither of
these methods should be considered
an endorsement by Puppet.

Version information

  • 5.0.4 (latest)
  • 5.0.3
  • 5.0.2
  • 5.0.1
  • 5.0.0
  • 4.5.0
  • 4.4.0
  • 4.3.4
  • 4.3.3
  • 4.3.2
  • 4.3.1
  • 4.3.0
  • 4.2.3
  • 4.2.2
  • 4.2.1
  • 4.2.0
  • 4.1.2
  • 4.1.1
  • 4.1.0
  • 4.0.0
  • 3.1.0
  • 3.0.0
  • 2.2.2
  • 2.2.1
  • 2.2.0
  • 2.1.5
  • 2.1.4
  • 2.1.3
  • 2.1.1
  • 2.1.0
  • 2.0.4
  • 2.0.2
  • 2.0.1
  • 2.0.0
released Nov 19th 2018
This version is compatible with:
  • Puppet Enterprise 2018.1.x, 2017.3.x, 2017.2.x, 2017.1.x, 2016.5.x, 2016.4.x
  • Puppet >=2.7.20 < 6.0.0
  • , ,

Start using this module

  • r10k or Code Manager
  • Bolt
  • Manual installation
  • Direct download

Add this module to your Puppetfile:

mod 'cirrax-libvirt', '2.2.2'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add cirrax-libvirt
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install cirrax-libvirt --version 2.2.2

Direct download is not typically how you would use a Puppet module to manage your infrastructure, but you may want to download the module in order to inspect the code.

Download

Documentation

cirrax/libvirt — version 2.2.2 Nov 19th 2018

libvirt puppet module

Build Status Puppet Forge Puppet Forge Puppet Forge Puppet Forge

Table of Contents

  1. Overview
  2. Module Description - What the module does and why it is useful
  3. Usage - Configuration options and additional functionality
  4. Reference
  5. Limitations - OS compatibility, etc.
  6. Development - Guide for contributing to the module

Overview

Puppet module to install libvirt and create virtual domain configuration. This module has very minimal external dependencies and tries to not make any assumptions about how you want to setup your virtual machines.

The module contains helper scripts to manage VMs on a 2 node cluster with disk replication over DRBD. But this is completely optional.

Description

This module tries to adhere to the Unix philosophy of doing one thing but doing it right. It installs and configures libvirt and virtual domains, but does not do the basic setup of your networking bridge or configure the disks used by the virtual domains. This is left to other puppet modules.

For a basic setup you have to include the libvirt class, define a libvirt::network and a libvirt::domain.

As an optional add-on this module contains a libvirt hook and a Python management script to create a 2 node cluster with disks replicated over DRBD. This setup allows live migration of VMs from one node to the other.

A complete working solution can be achived by integrating the following modules in addition to this module:

Usage

Install libvirt:

class {'libvirt': }

Install including the DRBD hook:

class {'libvirt':
  qemu_hook => 'drbd',
}

Define a network (basic linux bridge example):

libvirt::network { 'net-simple':
    forward_mode   => 'bridge',
    bridge         => 'br-simple',
}

Define a network (advanced openvswitch example):

libvirt::network { 'net-ovs':
  forward_mode     => 'bridge',
  bridge           => 'br-ovs',
  virtualport_type => 'openvswitch',
  autostart        => true,
  portgroups       => [
                       {'name'     => 'intern',
                        'trunk'    => false,
                        'vlan_tag' => '2',
                        },
                       {'name'     => 'trunk',
                        'trunk'    => true,
                        'vlan_tag' => ['100', '101', '102', ],
                        },
                       ],
}

Define a domain (VM):

libvirt::domain { 'my-domain':
  max_memory     => '2000',
  cpus           => 2,
  boot           => 'hd',
  disks          => [{'type' => 'block',
                      'device' => 'disk',
                      'source' => {'dev' => '/dev/vm-pool/my-domain.img'},
                      },
                     {'type'   => 'file',
                      'device' => 'disk',
                      'source' => {'dev' => '/var/lib/libvirt/images/my-disk.qcow2'},
                      'bus'    => 'virtio',
                      'driver' => {'name'  => 'qemu',
                                   'type'  => 'qcow2',
                                   'cache' => 'none',
                                   },
                     ],
  interfaces     => [{'network' => 'net-simple'},],
  autostart      => true,
}

Define a storage pool:

libvirt_pool { 'default' :
    ensure     => present,
    type       => 'logical',
    autostart  => true,
    sourcedev  => '/dev/sda5',
    sourcename => 'vm',
    target     => '/dev/vm',
}

Complete documentation is included in puppet doc format in the manifest files.

Reference

Functions

libvirt_generate_mac

Returns a MAC address in the QEMU/KVM MAC OID (52:54:00:...)

libvirt_generate_mac_addresses

Generates MAC addresses for all interfaces in the array which do not yet have an address specified. The MAC addresses are based on the domain name, network and portgroup.

Types

libvirt_pool

Manages libvirt pools

Example : libvirt_pool { 'default' : ensure => absent }

libvirt_pool { 'mydirpool' : ensure => present, active => true, autostart => true, type => 'dir', target => '/tmp/mypool', }

libvirt_pool { 'mydirpool2' : ensure => present, active => true, autostart => true, type => 'dir', target => '/tmp/mypool2', target_owner => 107, target_group => 107, target_mode => '0755', }

libvirt_pool { 'vm_storage': ensure => 'present', active => 'true', type => 'logical', sourcedev => ['/dev/sdb', '/dev/sdc'], target => '/dev/vg0' }

Properties

The following properties are available in the libvirt_pool type.

ensure

Valid values: present, absent

Manages the creation or the removal of a pool present means that the pool will be defined and created absent means that the pool will be purged from the system

Default value: present

active

Valid values: true, false

Whether the pool should be started.

Default value: true

autostart

Valid values: true, false

Whether the pool should be autostarted.

Default value: false

Parameters

The following parameters are available in the libvirt_pool type.

name

Valid values: /^\S+$/

namevar

The pool name.

type

Valid values: dir, netfs, fs, logical, disk, iscsi, mpath, rbd, sheepdog

The pool type.

sourcehost

Valid values: /^\S+$/

The source host.

sourcepath

Valid values: /(\/)?(\w)/

The source path.

sourcedev

Valid values: /(\/)?(\w)/

The source device.

sourcename

Valid values: /^\S+$/

The source name.

sourceformat

Valid values: auto, nfs, glusterfs, cifs

The source format.

target

Valid values: /(\/)?(\w)/

The target.

target_owner

Valid values: /^\S+$/

The owner of the target dir or filesystem

target_group

Valid values: /^\S+$/

The group of the target dir or filesystem

target_mode

Valid values: /^[0-7]{4}$/

The mode of the target dir or filesystem

Limitations

Things currently not supported:

  • Operating Systems other than Debian, Ubuntu or RedHat. Adding support for other systems is a matter of defining the relevant parameters in params.pp. So this is really easy for someone with access to such a system.
  • Network interfaces not attached to a libvirt network

Patches to support any of these (or other) missing features are welcome.

Contributing

Please report bugs and feature request using GitHub issue tracker.

For pull requests, it is very much appreciated to check your Puppet manifest with puppet-lint and the available spec tests in order to follow the recommended Puppet style guidelines from the Puppet Labs style guide.