aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2018-06-23 16:16:51 -0300
committerSilvio Rhatto <rhatto@riseup.net>2018-06-23 16:16:51 -0300
commit46f311f299d55236dc5d2fc7e35ce309067fbfd5 (patch)
treec60f243b5d49584853c3787a45e5caa6726eb13b
parent1a860b498c0b6979dd8ab4b3c6635df0f905e7c1 (diff)
downloadpuppet-virtual-46f311f299d55236dc5d2fc7e35ce309067fbfd5.tar.gz
puppet-virtual-46f311f299d55236dc5d2fc7e35ce309067fbfd5.tar.bz2
Commented working in progress to automatically create kvmx guests
-rw-r--r--manifests/kvm/kvmx/instance.pp64
1 files changed, 59 insertions, 5 deletions
diff --git a/manifests/kvm/kvmx/instance.pp b/manifests/kvm/kvmx/instance.pp
index e57c672..a0441d2 100644
--- a/manifests/kvm/kvmx/instance.pp
+++ b/manifests/kvm/kvmx/instance.pp
@@ -6,6 +6,7 @@ define virtual::kvm::kvmx::instance(
$iface,
$ip,
$gateway,
+ $create = false,
$guest_domain = 'example.org',
$dns = 'host',
$netmask = '255.255.255.0',
@@ -31,11 +32,6 @@ define virtual::kvm::kvmx::instance(
require => Virtual::Kvm::Instance["$name"], # due to udev rule
}
- file { "/home/${name}/vms/${name}/box.img":
- ensure => "/dev/mapper/${name}",
- require => Virtual::Kvm::Instance["$name"],
- }
-
exec { "kvmx-init-${name}":
command => "/usr/local/bin/kvmx init",
user => $name,
@@ -69,6 +65,12 @@ define virtual::kvm::kvmx::instance(
value => "\$HOME/vms/${name}/box.img",
}
+ virtual::kvm::kvmx::config { "${name}-datadir":
+ vm => $name,
+ param => 'datadir',
+ value => "\$HOME/vms/${name}",
+ }
+
virtual::kvm::kvmx::config { "${name}-net":
vm => $name,
param => 'net',
@@ -165,16 +167,68 @@ define virtual::kvm::kvmx::instance(
}
if $ssh_custom_pubkey == '' {
+ $ssh_custom_pubkey_set = ""
+ $ssh_custom_pubkey_unset = "${name}-ssh_custom_pubkey"
+
virtual::kvm::kvmx::config_unset { "${name}-ssh_custom_pubkey":
vm => $name,
param => 'ssh_custom_pubkey',
}
}
else {
+ $ssh_custom_pubkey_set = "${name}-ssh_custom_pubkey"
+ $ssh_custom_pubkey_unset = ""
+
virtual::kvm::kvmx::config { "${name}-ssh-custom_pubkey":
vm => $name,
param => 'ssh_custom_pubkey',
value => $ssh_custom_pubkey,
}
}
+
+ #file { "/home/${name}/vms/${name}/box.img":
+ # ensure => "/dev/mapper/${name}",
+ # require => Virtual::Kvm::Instance["$name"],
+ #}
+
+ #if $create == true {
+ # exec { "kvmx-lvcreate-${name}":
+ # command => "/usr/local/bin/kvmx create && chown -R ${name}: /home/${names}/vms/${name}",
+ # user => root,
+ # cwd => "/home/${name}/vms/${name}",
+ # creates => "/home/${name}/vms/${name}/box.img",
+ # require => [
+ # Exec["kvmx-lvcreate-${name}", "kvmx-init-${name}"],
+ # File["/home/${name}/vms/${name}/box.img"],
+ # Virtual::Kvm::Instance["$name"],
+ # Virtual::Kvm::Kvmx::Config[
+ # "${name}-user",
+ # "${name}-memory",
+ # "${name}-size",
+ # "${name}-image",
+ # "${name}-datadir",
+ # "${name}-net",
+ # "${name}-net_ip",
+ # "${name}-net_mask",
+ # "${name}-net_gateway",
+ # "${name}-net_dns",
+ # "${name}-domain",
+ # "${name}-spice",
+ # "${name}-run_spice_client",
+ # "${name}-graphics",
+ # "${name}-sound",
+ # "${name}-shared_folder",
+ # "${name}-format",
+ # "${name}-image_type",
+ # "${name}-ssh_support",
+ # "${name}-drive_interface",
+ # "${name}-supervise_manage",
+ # "${ssh_custom_pubkey_set}"
+ # ],
+ # Virtual::Kvm::Kvmx::Config_unset[
+ # "${ssh_custom_pubkey_unset}"
+ # ],
+ # ],
+ # }
+ #}
}