From 4b18be69d3635efd618deb8311c4a4fb2dd0c03e Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sat, 30 Dec 2017 22:34:26 -0200 Subject: KVMX support --- manifests/kvm/instance.pp | 19 ++++++++++++++++++ manifests/kvm/kvmx.pp | 41 +++++++++++++++++++++++++++++++++++++++ manifests/kvm/manager.pp | 13 ++----------- manifests/kvm/manager/instance.pp | 18 +++-------------- manifests/kvm/packages.pp | 15 ++++++++++++++ templates/kvm.rules.erb | 3 +++ templates/kvm_creator.rules.erb | 3 --- 7 files changed, 83 insertions(+), 29 deletions(-) create mode 100644 manifests/kvm/instance.pp create mode 100644 manifests/kvm/kvmx.pp create mode 100644 manifests/kvm/packages.pp create mode 100644 templates/kvm.rules.erb delete mode 100644 templates/kvm_creator.rules.erb diff --git a/manifests/kvm/instance.pp b/manifests/kvm/instance.pp new file mode 100644 index 0000000..57e3bf0 --- /dev/null +++ b/manifests/kvm/instance.pp @@ -0,0 +1,19 @@ +define virtual::kvm::instance( + $udev = false, +) { + user { $name: + ensure => present, + home => "/home/${name}", + groups => [ 'kvm' ], + } + + if $udev == true { + file { "/etc/udev/rules.d/92-kvm-${name}.rules": + ensure => present, + owner => root, + group => root, + mode => '0644', + content => template('virtual/kvm.rules.erb'), + } + } +} diff --git a/manifests/kvm/kvmx.pp b/manifests/kvm/kvmx.pp new file mode 100644 index 0000000..daed3d6 --- /dev/null +++ b/manifests/kvm/kvmx.pp @@ -0,0 +1,41 @@ +class virtual::kvm::kvmx { + include virtual::kvm::packages + include virtual::networking + + vcsrepo { '/usr/local/share/kvmx': + ensure => present, + provider => git, + source => 'https://git.fluxo.info/kvmx', + revision => 'd2263b94f93e0c0b7549c5a84c18834f8e6e8f58', + owner => 'root', + group => 'root', + } + + file { '/usr/local/bin/kvmx': + ensure => '/usr/local/share/kvmx/kvmx', + owner => 'root', + group => 'root', + require => Vcsrepo['/usr/local/share/kvmx'], + } + + file { '/usr/local/bin/kvmx-create': + ensure => '/usr/local/share/kvmx/kvmx-create', + owner => 'root', + group => 'root', + require => Vcsrepo['/usr/local/share/kvmx'], + } + + file { '/usr/local/bin/kvmx-status': + ensure => '/usr/local/share/kvmx/kvmx-status', + owner => 'root', + group => 'root', + require => Vcsrepo['/usr/local/share/kvmx'], + } + + file { '/usr/local/bin/kvmx-vdagent': + ensure => '/usr/local/share/kvmx/kvmx-vdagent', + owner => 'root', + group => 'root', + require => Vcsrepo['/usr/local/share/kvmx'], + } +} diff --git a/manifests/kvm/manager.pp b/manifests/kvm/manager.pp index 5c9b2fb..daed51e 100644 --- a/manifests/kvm/manager.pp +++ b/manifests/kvm/manager.pp @@ -1,28 +1,19 @@ class virtual::kvm::manager { + include virtual::kvm::packages include virtual::networking package { [ - 'qemu-kvm', 'runit', 'runit-systemd', 'uml-utilities', - 'qemu-kvm', - 'socat', - 'fakeroot', - 'xorriso', ]: ensure => present, } - # Provide a netboot image for VM installs - package { "debian-installer-9-netboot-${::architecture}": - ensure => present, - } - vcsrepo { '/usr/local/share/kvm-manager': ensure => present, provider => git, - source => 'git://git.fluxo.info/kvm-manager.git', + source => 'https://git.fluxo.info/kvm-manager', revision => 'b262c9597a3c5fd8c86ae63deda10f999048dfb8', owner => 'root', group => 'root', diff --git a/manifests/kvm/manager/instance.pp b/manifests/kvm/manager/instance.pp index 621a3ca..c9ecff9 100644 --- a/manifests/kvm/manager/instance.pp +++ b/manifests/kvm/manager/instance.pp @@ -11,26 +11,14 @@ define virtual::kvm::manager::instance( 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'), - } + virtual::kvmx::instance { "$name": + udev => $udev, + require => Exec["kvm-creator-${name}"], } } diff --git a/manifests/kvm/packages.pp b/manifests/kvm/packages.pp new file mode 100644 index 0000000..3505e7f --- /dev/null +++ b/manifests/kvm/packages.pp @@ -0,0 +1,15 @@ +class virtual::kvm::packages { + package { [ + 'qemu-kvm', + 'socat', + 'fakeroot', + 'xorriso', + ]: + ensure => present, + } + + # Provide a netboot image for VM installs + package { "debian-installer-9-netboot-${::architecture}": + ensure => present, + } +} diff --git a/templates/kvm.rules.erb b/templates/kvm.rules.erb new file mode 100644 index 0000000..8267d90 --- /dev/null +++ b/templates/kvm.rules.erb @@ -0,0 +1,3 @@ +ACTION=="change", SUBSYSTEM=="block", ATTR{dm/name}=="<%= scope.lookupvar('::hostname') %>-<%= @name %>", GROUP="<%= @name %>" +ACTION=="change", SUBSYSTEM=="block", ATTR{dm/name}=="<%= @name %>", GROUP="<%= @name %>" +ACTION=="change", SUBSYSTEM=="block", ATTR{dm/name}=="<%= @name %>1", GROUP="<%= @name %>" diff --git a/templates/kvm_creator.rules.erb b/templates/kvm_creator.rules.erb deleted file mode 100644 index 8267d90..0000000 --- a/templates/kvm_creator.rules.erb +++ /dev/null @@ -1,3 +0,0 @@ -ACTION=="change", SUBSYSTEM=="block", ATTR{dm/name}=="<%= scope.lookupvar('::hostname') %>-<%= @name %>", GROUP="<%= @name %>" -ACTION=="change", SUBSYSTEM=="block", ATTR{dm/name}=="<%= @name %>", GROUP="<%= @name %>" -ACTION=="change", SUBSYSTEM=="block", ATTR{dm/name}=="<%= @name %>1", GROUP="<%= @name %>" -- cgit v1.2.3