aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2018-06-14 01:41:33 -0300
committerSilvio Rhatto <rhatto@riseup.net>2018-06-14 01:41:33 -0300
commit18475fc0a942c8e545b3a2cec5ae5633d64d529f (patch)
tree2c0ed96e096c541ac16db877f4d28d7e10945e15
parent5b4894bcd12659e22c936d15aac1c38f121528d0 (diff)
downloadpuppet-virtual-18475fc0a942c8e545b3a2cec5ae5633d64d529f.tar.gz
puppet-virtual-18475fc0a942c8e545b3a2cec5ae5633d64d529f.tar.bz2
KVMX enhancements
-rw-r--r--manifests/kvm/images.pp2
-rw-r--r--manifests/kvm/instance.pp6
-rw-r--r--manifests/kvm/kvmx.pp2
-rw-r--r--manifests/kvm/kvmx/instance.pp68
4 files changed, 74 insertions, 4 deletions
diff --git a/manifests/kvm/images.pp b/manifests/kvm/images.pp
index 48a46c9..f973373 100644
--- a/manifests/kvm/images.pp
+++ b/manifests/kvm/images.pp
@@ -28,7 +28,7 @@ class virtual::kvm::images {
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/profiles/kvm.preseed"], Package['simple-cdd'] ],
+ require => [ File["/usr/local/share/iso/${lsbdistcodename}/installer/profiles/kvm-unencrypted.preseed"], Package['simple-cdd'] ],
}
exec { "debirf-make-profile-rescue-${lsbdistcodename}":
diff --git a/manifests/kvm/instance.pp b/manifests/kvm/instance.pp
index bffedfa..874a1e1 100644
--- a/manifests/kvm/instance.pp
+++ b/manifests/kvm/instance.pp
@@ -37,5 +37,11 @@ define virtual::kvm::instance(
content => template('virtual/kvm.rules.erb'),
require => User[$name],
}
+
+ exec { "udev-reload-kvm-${name}":
+ command => "/sbin/udevadm control --reload-rules && /sbin/udevadm trigger",
+ refreshonly => true,
+ subscribe => File["/etc/udev/rules.d/92-kvm-${name}.rules"],
+ }
}
}
diff --git a/manifests/kvm/kvmx.pp b/manifests/kvm/kvmx.pp
index 4711f25..862c52a 100644
--- a/manifests/kvm/kvmx.pp
+++ b/manifests/kvm/kvmx.pp
@@ -7,7 +7,7 @@ class virtual::kvm::kvmx {
ensure => present,
provider => git,
source => 'https://git.fluxo.info/kvmx',
- revision => 'cbe2e6f3c4dd81879aaec84546e0b9f86d67c1d0',
+ revision => 'fe4859aee4eeddbcb0b81b03fe3608383f431710',
owner => 'root',
group => 'root',
}
diff --git a/manifests/kvm/kvmx/instance.pp b/manifests/kvm/kvmx/instance.pp
index b0b30ba..dd6cdb6 100644
--- a/manifests/kvm/kvmx/instance.pp
+++ b/manifests/kvm/kvmx/instance.pp
@@ -4,8 +4,15 @@ define virtual::kvm::kvmx::instance(
$ram,
$shell,
$iface,
- $udev = false,
- $supervise = '1',
+ $ip,
+ $gateway,
+ $guest_domain = 'example.org',
+ $dns = 'host',
+ $netmask = '255.255.255.0',
+ $initial_user = 'user',
+ $udev = false,
+ $supervise = '1',
+ $ssh_custom_pubkey = '',
) {
virtual::kvm::instance { $name:
udev => $udev,
@@ -21,6 +28,7 @@ define virtual::kvm::kvmx::instance(
user => root,
creates => "/dev/${vg}/${name}",
#onlyif => "test ! -e /dev/${vg}/${name}"
+ require => Virtual::Kvm::Instance["$name"], # due to udev rule
}
exec { "kvmx-init-${name}":
@@ -32,6 +40,12 @@ define virtual::kvm::kvmx::instance(
require => Virtual::Kvm::Instance["$name"],
}
+ virtual::kvm::kvmx::config { "${name}-user":
+ vm => $name,
+ param => 'user',
+ value => $initial_user,
+ }
+
virtual::kvm::kvmx::config { "${name}-memory":
vm => $name,
param => 'memory',
@@ -56,6 +70,36 @@ define virtual::kvm::kvmx::instance(
value => "tap",
}
+ virtual::kvm::kvmx::config { "${name}-net_ip":
+ vm => $name,
+ param => 'net_ip',
+ value => "$ip",
+ }
+
+ virtual::kvm::kvmx::config { "${name}-net_mask":
+ vm => $name,
+ param => 'net_mask',
+ value => "$netmask",
+ }
+
+ virtual::kvm::kvmx::config { "${name}-net_gateway":
+ vm => $name,
+ param => 'net_gateway',
+ value => "$gateway",
+ }
+
+ virtual::kvm::kvmx::config { "${name}-net_dns":
+ vm => $name,
+ param => 'net_dns',
+ value => "$dns",
+ }
+
+ virtual::kvm::kvmx::config { "${name}-domain":
+ vm => $name,
+ param => 'domain',
+ value => "$guest_domain",
+ }
+
virtual::kvm::kvmx::config { "${name}-spice":
vm => $name,
param => 'spice',
@@ -91,6 +135,12 @@ define virtual::kvm::kvmx::instance(
value => "raw",
}
+ virtual::kvm::kvmx::config { "${name}-image_type":
+ vm => $name,
+ param => 'image_type',
+ value => "device",
+ }
+
virtual::kvm::kvmx::config { "${name}-ssh_support":
vm => $name,
param => 'ssh_support',
@@ -108,4 +158,18 @@ define virtual::kvm::kvmx::instance(
param => 'supervise_manage',
value => "${supervise}",
}
+
+ if $ssh_custom_pubkey == '' {
+ virtual::kvm::kvmx::config_unset { "${name}-ssh_custom_pubkey":
+ vm => $name,
+ param => 'ssh_custom_pubkey',
+ }
+ }
+ else {
+ virtual::kvm::kvmx::config { "${name}-ssh-custom_pubkey":
+ vm => $name,
+ param => 'ssh_custom_pubkey',
+ value => $ssh_custom_pubkey,
+ }
+ }
}