Puppet Class: kvm

Defined in:
manifests/init.pp

Summary

Configure KVM hosting

Overview

Parameters:

  • image_path (String)

    sets the base directory for image storage

  • console_path (String) (defaults to: '/var/lib/kvm')

    sets the location for QEMU/serial sockets

  • images (Hash[String, Hash]) (defaults to: [])

    sets the OS images to use for bootstrapping VMs

  • guests (Hash[String, Hash]) (defaults to: {})

    sets guest VM information for management



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'manifests/init.pp', line 7

class kvm (
  String $image_path,
  String $console_path = '/var/lib/kvm',
  Hash[String, Hash] $images = [],
  Hash[String, Hash] $guests = {},
) {
  package { [
      'qemu-base',
      'socat',
  ]: }

  file { [$console_path, "${console_path}/vnc", "${console_path}/serial",  "${console_path}/monitor"]:
    ensure => directory,
    owner  => 'root',
    group  => 'root',
    mode   => '0755',
  }

  $images.each | String $name, Hash $options | {
    kvm::image { $name:
      * => $options,
    }
  }

  $guests.each | String $name, Hash $options | {
    kvm::guest { $name:
      * => $options,
    }
  }

  file { '/etc/qemu':
    ensure => directory,
    owner  => 'root',
    group  => 'root',
    mode   => '0755',
  }

  file { '/etc/qemu/bridge.conf':
    ensure  => file,
    content => template('kvm/bridge.conf.erb'),
  }

  file { '/etc/kvm':
    ensure => directory,
    owner  => 'root',
    group  => 'root',
    mode   => '0755',
  }

  file { '/etc/systemd/system/kvm@.service':
    ensure => file,
    source => 'puppet:///modules/kvm/kvm@.service',
  }
}