aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--manifests/kvm/manager.pp56
-rw-r--r--manifests/kvm/manager/instance.pp25
2 files changed, 81 insertions, 0 deletions
diff --git a/manifests/kvm/manager.pp b/manifests/kvm/manager.pp
new file mode 100644
index 0000000..8b2b75e
--- /dev/null
+++ b/manifests/kvm/manager.pp
@@ -0,0 +1,56 @@
+class virtual::kvm::manager {
+ package { [ 'qemu-kvm', 'runit', 'uml-utilities', 'qemu-kvm', 'socat', 'bridge-utils', 'fakeroot', 'xorriso' ]:
+ ensure => present,
+ }
+
+ vcsrepo { '/usr/local/share/kvm-manager':
+ ensure => present,
+ provider => git,
+ source => 'git://git.fluxo.info/kvm-manager.git',
+ revision => 'd8bd926096ecf6d8c38453b6752088b8a10ca3b7',
+ owner => 'root',
+ group => 'root',
+ }
+
+ file { '/usr/local/sbin/di-maker':
+ ensure => '/usr/local/share/kvm-manager/di-maker',
+ owner => 'root',
+ group => 'root',
+ require => Vcsrepo['/usr/local/share/kvm-manager'],
+ }
+
+ file { '/usr/local/sbin/kvm-manager':
+ ensure => '/usr/local/share/kvm-manager/kvm-manager',
+ owner => 'root',
+ group => 'root',
+ require => Vcsrepo['/usr/local/share/kvm-manager'],
+ }
+
+ file { '/usr/local/sbin/kvm-creator':
+ ensure => '/usr/local/share/kvm-manager/kvm-creator',
+ owner => 'root',
+ group => 'root',
+ require => Vcsrepo['/usr/local/share/kvm-manager'],
+ }
+
+ file { '/usr/local/sbin/kvm-status':
+ ensure => '/usr/local/share/kvm-manager/kvm-status',
+ owner => 'root',
+ group => 'root',
+ require => Vcsrepo['/usr/local/share/kvm-manager'],
+ }
+
+ file { '/etc/screenrc.kvm-manager':
+ ensure => '/usr/local/share/kvm-manager/screenrc.kvm-manager',
+ owner => 'root',
+ group => 'root',
+ require => Vcsrepo['/usr/local/share/kvm-manager'],
+ }
+
+ file { '/dev/kvm':
+ ensure => present,
+ owner => "root",
+ group => "kvm",
+ mode => "660",
+ }
+}
diff --git a/manifests/kvm/manager/instance.pp b/manifests/kvm/manager/instance.pp
new file mode 100644
index 0000000..598e4d2
--- /dev/null
+++ b/manifests/kvm/manager/instance.pp
@@ -0,0 +1,25 @@
+class virtual::kvm::manager::instance(
+ $vg,
+ $size,
+ $ram,
+) {
+ 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,
+ homedir => "/home/${name}",
+ groups => [ 'kvm' ],
+ require => Exec["kvm-creator-${name}"],
+ }
+
+ exec { "update-service-kvm-${name}":
+ comand => "/usr/sbin/update-service --add /etc/sv/kvm/${name}",
+ creates => "/etc/service/${name}",
+ require => [ Exec["kvm-creator-${name}"], User["${name}"] ],
+ }
+}