aboutsummaryrefslogtreecommitdiff
path: root/manifests/kvm/kvmx/instance.pp
blob: c8c7d31fbcb3575b0bc965b32a15432212094531 (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
define virtual::kvm::kvmx::instance(
  $vg,
  $size,
  $ram,
  $shell,
  $udev      = false,
  $supervise = 1,
) {
  virtual::kvm::instance { $name:
    udev  => $udev,
    shell => $shell ? {
      undef   => '/usr/local/bin/kvmx-restricted-shell',
      default => $shell,
    },
  }

  exec { "kvmx-lvcreate-${name}":
    command => "/sbin/lvcreate --name ${name} --size ${size} ${vg}",
    user    => root,
    creates => "/dev/${vg}/${name}",
    #onlyif  => "test ! -e /dev/${vg}/${name}"
  }

  exec { "kvmx-init-${name}":
    command     => "/usr/local/bin/kvmx init",
    user        => $name,
    environment => [ "HOME=/home/${name}" ],
    cwd         => "/home/${name}/vms/${name}",
    creates     => "/home/${name}/vms/${name}/kvmxfile",
    require     => Virtual::Kvm::Instance["$name"],
  }

  virtual::kvm::kvmx::config { "${name}-memory":
    vm    => $name,
    param => 'memory',
    value => $ram,
  }

  virtual::kvm::kvmx::config { "${name}-size":
    vm    => $name,
    param => 'size',
    value => $size,
  }

  virtual::kvm::kvmx::config { "${name}-image":
    vm    => $name,
    param => 'image',
    value => "\$HOME/vms/${name}/box.img",
  }

  virtual::kvm::kvmx::config { "${name}-net":
    vm    => $name,
    param => 'net',
    value => "tap",
  }

  virtual::kvm::kvmx::config { "${name}-spice":
    vm    => $name,
    param => 'spice',
    value => "0",
  }

  virtual::kvm::kvmx::config { "${name}-run_spice_client":
    vm    => $name,
    param => 'run_spice_client',
    value => "0",
  }

  virtual::kvm::kvmx::config { "${name}-graphics":
    vm    => $name,
    param => 'graphics',
    value => "-nographic",
  }

  virtual::kvm::kvmx::config { "${name}-sound":
    vm    => $name,
    param => 'sound',
    value => "0",
  }

  virtual::kvm::kvmx::config_unset { "${name}-shared_folder":
    vm    => $name,
    param => 'shared_folder',
  }

  virtual::kvm::kvmx::config { "${name}-format":
    vm    => $name,
    param => 'format',
    value => "raw",
  }

  virtual::kvm::kvmx::config { "${name}-ssh_support":
    vm    => $name,
    param => 'ssh_support',
    value => "n",
  }

  virtual::kvm::kvmx::config { "${name}-drive_interface":
    vm    => $name,
    param => 'drive_interface',
    value => "virtio,cache=none,index=0,format=raw",
  }

  virtual::kvm::kvmx::config { "${name}-supervise_manage":
    vm    => $name,
    param => 'supervise_manage',
    value => "${supervise}",
  }
}