diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2018-06-10 13:43:58 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2018-06-10 13:43:58 -0300 |
commit | 92342cd1bfcd0129a1526fe0773ee69ff14a3e29 (patch) | |
tree | 41e17a7f232f97993112e9698ab3de5536d2542b | |
parent | ea9db62363bcfb895b3227f68b221563a9e14811 (diff) | |
download | puppet-virtual-92342cd1bfcd0129a1526fe0773ee69ff14a3e29.tar.gz puppet-virtual-92342cd1bfcd0129a1526fe0773ee69ff14a3e29.tar.bz2 |
KVMX: basic volume, kvmxfile, ram and size management
-rw-r--r-- | manifests/kvm/instance.pp | 9 | ||||
-rw-r--r-- | manifests/kvm/kvmx.pp | 2 | ||||
-rw-r--r-- | manifests/kvm/kvmx/instance.pp | 54 |
3 files changed, 46 insertions, 19 deletions
diff --git a/manifests/kvm/instance.pp b/manifests/kvm/instance.pp index 81b2a4a..562d8d3 100644 --- a/manifests/kvm/instance.pp +++ b/manifests/kvm/instance.pp @@ -9,6 +9,14 @@ define virtual::kvm::instance( shell => $shell, } + file { [ "/home/${name}", "/home/${name}/vms", "/home/${name}/vms/${name}" ]: + ensure => directory, + owner => $name, + group => $name, + mode => '0755', + require => User[$name], + } + if $udev == true { file { "/etc/udev/rules.d/92-kvm-${name}.rules": ensure => present, @@ -16,6 +24,7 @@ define virtual::kvm::instance( group => root, mode => '0644', content => template('virtual/kvm.rules.erb'), + require => User[$name], } } } diff --git a/manifests/kvm/kvmx.pp b/manifests/kvm/kvmx.pp index 4f4d5ae..5a7db84 100644 --- a/manifests/kvm/kvmx.pp +++ b/manifests/kvm/kvmx.pp @@ -6,7 +6,7 @@ class virtual::kvm::kvmx { ensure => present, provider => git, source => 'https://git.fluxo.info/kvmx', - revision => '9903bf0df5dcda03ed1505bef247e84cc4a17ec4', + revision => '7ed7c785f4731b7b0d7d1b2474d658ae4fe731ea', owner => 'root', group => 'root', } diff --git a/manifests/kvm/kvmx/instance.pp b/manifests/kvm/kvmx/instance.pp index 76d1bb3..ee1dac3 100644 --- a/manifests/kvm/kvmx/instance.pp +++ b/manifests/kvm/kvmx/instance.pp @@ -1,4 +1,5 @@ define virtual::kvm::kvmx::instance( + $vg, $size, $ram, $shell, @@ -12,24 +13,41 @@ define virtual::kvm::kvmx::instance( }, } - #exec { "kvmx-init-${name}": - # command => "/usr/local/bin/kvmx init $name", - # user => $name, - # creates => "/home/${name}/vms/${name}/kvmxfile", - # require => Virtual::Kvm::Instance["$name"], - #} + exec { "kvmx-lvcreate-${name}": + command => "/sbin/lvcreate --name ${name} --size ${size} ${vg}", + user => root, + creates => "/dev/${vg}/${name}", + #onlyif => "test ! -e /dev/${vg}/${name}" + } - #exec { "kvmx-config-${name}-ram": - # command => "/usr/local/bin/kvmx config $name memory $ram", - # user => $name, - # onlyif => "/usr/local/bin/kvmx config $name memory | grep -v memory=\"${ram}\"", - # require => Exec["kvmx-init-${name}"], - #} + exec { "kvmx-init-${name}": + command => "/usr/local/bin/kvmx init", + user => $name, + environment => [ "HOME=/home/${name}" ], + cwd => "/home/${name}/vms/${name}", + creates => "/home/${name}/vms/${name}/kvmxfile", + require => Virtual::Kvm::Instance["$name"], + } - #exec { "kvmx-config-${name}-size": - # command => "/usr/local/bin/kvmx config $name size $size", - # user => $name, - # onlyif => "/usr/local/bin/kvmx config $name size | grep -v memory=\"${size}\"", - # require => Exec["kvmx-init-${name}"], - #} + exec { "kvmx-config-${name}-ram": + #command => "/usr/local/bin/kvmx $name config memory ${ram}", + command => "/usr/local/bin/kvmx config memory ${ram}", + user => $name, + environment => [ "HOME=/home/${name}" ], + cwd => "/home/${name}/vms/${name}", + #onlyif => "/usr/local/bin/kvmx config ${name} memory | grep -v memory=\"${ram}\"", + onlyif => "/usr/local/bin/kvmx config ${name} memory | grep -v ^${ram}", + require => Exec["kvmx-init-${name}"], + } + + exec { "kvmx-config-${name}-size": + #command => "/usr/local/bin/kvmx ${name} config size ${size}", + command => "/usr/local/bin/kvmx config size ${size}", + user => $name, + environment => [ "HOME=/home/${name}" ], + cwd => "/home/${name}/vms/${name}", + #onlyif => "/usr/local/bin/kvmx config ${name} size | grep -v memory=\"${size}\"", + onlyif => "/usr/local/bin/kvmx config ${name} size | grep -v ^${size}", + require => Exec["kvmx-init-${name}"], + } } |