From 2410faceba2cff819f2d58f444aa8604cf95d9fc Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Thu, 16 Jun 2016 13:30:38 -0300 Subject: Initial kvm-manager support --- manifests/kvm/manager.pp | 56 +++++++++++++++++++++++++++++++++++++++ manifests/kvm/manager/instance.pp | 25 +++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 manifests/kvm/manager.pp create mode 100644 manifests/kvm/manager/instance.pp 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}"] ], + } +} -- cgit v1.2.3