aboutsummaryrefslogtreecommitdiff
path: root/manifests/kvm/manager/instance.pp
blob: 621a3ca605d08a1586053a42cf16cad6b15a6c89 (plain)
1
2
3
4
5
6
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
define virtual::kvm::manager::instance(
  $vg,
  $size,
  $ram,
  $udev = false,
) {
  exec { "kvm-creator-${name}":
    command => "/usr/local/sbin/kvm-creator create $name $vg $size $ram",
    user    => "root",
    #creates => "/home/${name}/vms/${name}",
    creates => "/etc/sv/kvm/${name}",
  }

  user { $name:
    ensure  => present,
    home    => "/home/${name}",
    groups  => [ 'kvm' ],
    require => Exec["kvm-creator-${name}"],
  }

  exec { "update-service-kvm-${name}":
    command => "/usr/sbin/update-service --add /etc/sv/kvm/${name}",
    creates => "/etc/service/${name}",
    require => [ Exec["kvm-creator-${name}"], User["${name}"] ],
  }

  if $udev == true {
    file { "/etc/udev/rules.d/92-kvm_creator-${name}.rules":
      ensure  => present,
      owner   => root,
      group   => root,
      mode    => '0644',
      content => template('virtual/kvm_creator.rules.erb'),
    }
  }
}