From 46f311f299d55236dc5d2fc7e35ce309067fbfd5 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sat, 23 Jun 2018 16:16:51 -0300 Subject: Commented working in progress to automatically create kvmx guests --- manifests/kvm/kvmx/instance.pp | 64 ++++++++++++++++++++++++++++++++++++++---- 1 file 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}" + # ], + # ], + # } + #} } -- cgit v1.2.3