aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2018-06-11 16:11:09 -0300
committerSilvio Rhatto <rhatto@riseup.net>2018-06-11 16:11:09 -0300
commitf2da08baf6042c3931617ce348e04401fabe385e (patch)
treeb0a63cf3fcf886a8f92fdc6c0a521a225b1a66d2
parenta324c9c0840733903f45c5baaf05ba9388d6237b (diff)
downloadpuppet-virtual-f2da08baf6042c3931617ce348e04401fabe385e.tar.gz
puppet-virtual-f2da08baf6042c3931617ce348e04401fabe385e.tar.bz2
KVM: image, interface handling and other improvements
-rw-r--r--manifests/kvm/images.pp49
-rw-r--r--manifests/kvm/instance.pp10
-rw-r--r--manifests/kvm/kvmx.pp3
-rw-r--r--manifests/kvm/kvmx/instance.pp4
-rw-r--r--manifests/kvm/manager.pp1
-rw-r--r--manifests/kvm/manager/instance.pp2
-rw-r--r--manifests/kvm/packages.pp2
-rw-r--r--templates/interface.erb9
8 files changed, 78 insertions, 2 deletions
diff --git a/manifests/kvm/images.pp b/manifests/kvm/images.pp
new file mode 100644
index 0000000..64876e9
--- /dev/null
+++ b/manifests/kvm/images.pp
@@ -0,0 +1,49 @@
+class virtual::kvm::images {
+ user { 'iso':
+ ensure => present,
+ home => "/usr/local/share/iso",
+ }
+
+ file { [ '/usr/local/share/iso', "/usr/local/share/iso/${lsbdistcodename}", "/usr/local/share/iso/${lsbdistcodename}/installer" ]:
+ ensure => directory,
+ owner => iso,
+ group => iso,
+ mode => '0755',
+ require => User['iso'],
+ }
+
+ exec { "build-simple-cdd-${lsbdistcodename}":
+ command => '/usr/bin/build-simple-cdd --serial-console',
+ user => 'iso',
+ timeout => 0,
+ cwd => "/usr/local/share/iso/${lsbdistcodename}/installer",
+ creates => "/usr/local/share/iso/${lsbdistcodename}/installer/images/debian-${lsbdistrelease}-${architecture}-CD-1.iso",
+ require => [ File["/usr/local/share/iso/${lsbdistcodename}/installer"], Package['simple-cdd'] ],
+ }
+
+ exec { "debirf-make-profile-rescue-${lsbdistcodename}":
+ command => 'tar xzf /usr/share/doc/debirf/example-profiles/rescue.tgz',
+ user => 'iso',
+ cwd => "/usr/local/share/iso/${lsbdistcodename}",
+ creates => "/usr/local/share/iso/${lsbdistcodename}/rescue",
+ require => [ File["/usr/local/share/iso/${lsbdistcodename}"], Package['debirf'] ],
+ }
+
+ exec { "debirf-make-rescue-${lsbdistcodename}":
+ command => '/usr/bin/debirf make rescue',
+ user => 'iso',
+ timeout => 0,
+ creates => "/usr/local/share/iso/${lsbdistcodename}/rescue/vmlinuz-${kernelrelease}",
+ cwd => "/usr/local/share/iso/${lsbdistcodename}",
+ require => Exec["debirf-make-profile-rescue-${lsbdistcodename}"],
+ }
+
+ exec { "debirf-makeiso-rescue-${lsbdistcodename}":
+ command => '/usr/bin/debirf makeiso rescue',
+ user => 'iso',
+ timeout => 0,
+ creates => "/usr/local/share/iso/${lsbdistcodename}/rescue/debirf-rescue_${lsbdistcodename}_${kernelrelease}.iso",
+ cwd => "/usr/local/share/iso/${lsbdistcodename}",
+ require => Exec["debirf-make-rescue-${lsbdistcodename}"],
+ }
+}
diff --git a/manifests/kvm/instance.pp b/manifests/kvm/instance.pp
index 562d8d3..6341289 100644
--- a/manifests/kvm/instance.pp
+++ b/manifests/kvm/instance.pp
@@ -1,4 +1,5 @@
define virtual::kvm::instance(
+ $iface,
$udev = false,
$shell = undef,
) {
@@ -17,6 +18,15 @@ define virtual::kvm::instance(
require => User[$name],
}
+ file { "/etc/network/interfaces.d/${name}":
+ ensure => present,
+ owner => root,
+ group => root,
+ mode => '0644',
+ content => template('virtual/interface.erb'),
+ require => User[$name],
+ }
+
if $udev == true {
file { "/etc/udev/rules.d/92-kvm-${name}.rules":
ensure => present,
diff --git a/manifests/kvm/kvmx.pp b/manifests/kvm/kvmx.pp
index 0818103..caa9363 100644
--- a/manifests/kvm/kvmx.pp
+++ b/manifests/kvm/kvmx.pp
@@ -1,12 +1,13 @@
class virtual::kvm::kvmx {
include virtual::kvm::packages
+ include virtual::kvm::images
include virtual::networking
vcsrepo { '/usr/local/share/kvmx':
ensure => present,
provider => git,
source => 'https://git.fluxo.info/kvmx',
- revision => '8356c30791a582ffc357a5522cc5ec9e6c7140a2',
+ revision => '6056a2718f92e9fa54807451ff7f553ad08aff20',
owner => 'root',
group => 'root',
}
diff --git a/manifests/kvm/kvmx/instance.pp b/manifests/kvm/kvmx/instance.pp
index c8c7d31..b0b30ba 100644
--- a/manifests/kvm/kvmx/instance.pp
+++ b/manifests/kvm/kvmx/instance.pp
@@ -3,11 +3,13 @@ define virtual::kvm::kvmx::instance(
$size,
$ram,
$shell,
+ $iface,
$udev = false,
- $supervise = 1,
+ $supervise = '1',
) {
virtual::kvm::instance { $name:
udev => $udev,
+ iface => $iface,
shell => $shell ? {
undef => '/usr/local/bin/kvmx-restricted-shell',
default => $shell,
diff --git a/manifests/kvm/manager.pp b/manifests/kvm/manager.pp
index daed51e..d30d1e4 100644
--- a/manifests/kvm/manager.pp
+++ b/manifests/kvm/manager.pp
@@ -1,5 +1,6 @@
class virtual::kvm::manager {
include virtual::kvm::packages
+ include virtual::kvm::images
include virtual::networking
package { [
diff --git a/manifests/kvm/manager/instance.pp b/manifests/kvm/manager/instance.pp
index 76bb2aa..781bed2 100644
--- a/manifests/kvm/manager/instance.pp
+++ b/manifests/kvm/manager/instance.pp
@@ -2,6 +2,7 @@ define virtual::kvm::manager::instance(
$vg,
$size,
$ram,
+ $iface,
$udev = false,
) {
exec { "kvm-creator-${name}":
@@ -19,6 +20,7 @@ define virtual::kvm::manager::instance(
virtual::kvm::instance { "$name":
udev => $udev,
+ iface => $iface,
require => Exec["kvm-creator-${name}"],
}
}
diff --git a/manifests/kvm/packages.pp b/manifests/kvm/packages.pp
index 3505e7f..688e5fa 100644
--- a/manifests/kvm/packages.pp
+++ b/manifests/kvm/packages.pp
@@ -4,6 +4,8 @@ class virtual::kvm::packages {
'socat',
'fakeroot',
'xorriso',
+ 'debirf',
+ 'simple-cdd',
]:
ensure => present,
}
diff --git a/templates/interface.erb b/templates/interface.erb
new file mode 100644
index 0000000..89ec8f9
--- /dev/null
+++ b/templates/interface.erb
@@ -0,0 +1,9 @@
+auto <%= @name %>0
+iface <%= @name %>0 inet manual
+ pre-up ip tuntap add dev <%= @name %>0 mode tap user <%= @name %>
+ pre-up ip link set <%= @name %>0 up
+ pre-up brctl addif <%= @iface %> <%= @name %>0
+ pre-down brctl delif <%= @iface %> <%= @name %>0
+ pre-down ip link set <%= @name %>0 down
+ pre-down ip tuntap del mode tap dev <%= @name %>0
+ post-up /usr/sbin/service shorewall reload