From fc0da24919241c2b2d2bff95ccad4bbd9707d0ca Mon Sep 17 00:00:00 2001 From: Micah Anderson Date: Sun, 4 Nov 2007 23:44:54 +0000 Subject: add an alias for the present option and add a delete option also move the order so it is consistant --- manifests/vserver.pp | 44 +++++++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 13 deletions(-) (limited to 'manifests/vserver.pp') diff --git a/manifests/vserver.pp b/manifests/vserver.pp index 105d5e3..968e949 100644 --- a/manifests/vserver.pp +++ b/manifests/vserver.pp @@ -33,7 +33,7 @@ define vs_create($in_domain, $legacy = false, $distro = 'etch') { # ensure: present, stopped, running -define vserver($ensure, $context, $in_domain = '', $mark = '', $legacy = false) { +define vserver($ensure, $context, $in_domain = '', $mark = '', $legacy = false, $distro = '') { case $in_domain { '': {} default: { err("${fqdn}: vserver ${name} uses deprecated \$in_domain" ) } @@ -48,9 +48,10 @@ define vserver($ensure, $context, $in_domain = '', $mark = '', $legacy = false) # TODO: wasn't there a syntax for using arrays as case selectors?? case $ensure { - present: { vs_create{$name: in_domain => $in_domain, legacy => $legacy, } } - running: { vs_create{$name: in_domain => $in_domain, legacy => $legacy, } } - stopped: { vs_create{$name: in_domain => $in_domain, legacy => $legacy, } } + present: { vs_create{$name: in_domain => $in_domain, legacy => $legacy, distro => $distro, } } + running: { vs_create{$name: in_domain => $in_domain, legacy => $legacy, distro => $distro, } } + stopped: { vs_create{$name: in_domain => $in_domain, legacy => $legacy, distro => $distro, } } + absent: { vs_create{$name: in_domain => $in_domain, legacy => $legacy, distro => $distro, } } default: { err("${fqdn}: vserver(${vs_name}): unknown ensure '${ensure}'") } } @@ -79,15 +80,16 @@ define vserver($ensure, $context, $in_domain = '', $mark = '', $legacy = false) } case $ensure { - stopped: { - exec { "vserver ${vs_name} stop": - onlyif => "test -e \$(readlink -f /etc/vservers/${vs_name}/run || echo /doesntexist )", - require => Exec["vs_create_${vs_name}"], - # fake the restart exec in the stopped case, so the dependencies are fulfilled - alias => "vs_restart_${vs_name}", - } - file { $mark_file: ensure => absent, } - } + + + present: { + # don't start or stop the vserver, just make sure it exists, we just run a dummy status test here + exec { "vserver ${vs_name} status": + require => Exec["vs_create_${vs_name}"], + alias => "vs_restart_${vs_name}", + } + } + running: { exec { "vserver ${vs_name} start": unless => "test -e \$(readlink -f /etc/vservers/${vs_name}/run)", @@ -114,6 +116,22 @@ define vserver($ensure, $context, $in_domain = '', $mark = '', $legacy = false) } } } + + stopped: { + exec { "vserver ${vs_name} stop": + onlyif => "test -e \$(readlink -f /etc/vservers/${vs_name}/run || echo /doesntexist )", + require => Exec["vs_create_${vs_name}"], + # fake the restart exec in the stopped case, so the dependencies are fulfilled + alias => "vs_restart_${vs_name}", + } + file { $mark_file: ensure => absent, } + } + + absent: { + exec { "vserver ${vs_name} delete": + onlyif => "test -e \$(readlink -f /etc/vservers/${vs_name}/run || echo /doesntexist )", + } + } } } -- cgit v1.2.3