diff options
-rw-r--r-- | files/vserver/build_vserver | 19 | ||||
-rw-r--r-- | manifests/vserver.pp | 63 |
2 files changed, 64 insertions, 18 deletions
diff --git a/files/vserver/build_vserver b/files/vserver/build_vserver index 3645ea9..569451b 100644 --- a/files/vserver/build_vserver +++ b/files/vserver/build_vserver @@ -4,16 +4,23 @@ NAME=$1 CONTEXT=$2 RELEASE=$3 DEBOOTSTRAP_MIRROR=$4 -# create basic vserver -vserver $NAME build -m debootstrap -- -d $RELEASE -m $DEBOOTSTRAP_MIRROR +HOSTNAME=$5 +INTERFACE=$6 + +if [ $HOSTNAME != "none" ]; then + hostname="--hostname $HOSTNAME" +fi -# default settings -echo $NAME >/etc/vservers/$NAME/uts/nodename -echo $CONTEXT >/etc/vservers/$NAME/context +if [ ! -z $INTERFACE]; then + interface="--interface $INTERFACE" +fi + +# create basic vserver +vserver $NAME build -n $NAME --context $CONTEXT \ + $hostname $interace -m debootstrap -- -d $RELEASE -m $DEBOOTSTRAP_MIRROR # copy in some some defaults TARGET=/etc/vservers/$NAME/vdir/ - cp /etc/apt/{preferences,sources.list} $TARGET/etc/apt/ # this is needed so puppet can find the puppetmaster and creates the right diff --git a/manifests/vserver.pp b/manifests/vserver.pp index f29b9d6..4709ac8 100644 --- a/manifests/vserver.pp +++ b/manifests/vserver.pp @@ -101,10 +101,10 @@ class vserver::host { } } -# TODO: hostname define vs_create($in_domain, $context, $legacy = false, $distro = 'etch', - $debootstrap_mirror = 'http://ftp.debian.org/debian', $hostname = false) { - $vs_name = $legacy ? { true => $name, false => $in_domain ? { '' => $name, default => "${name}.${in_domain}" } } + $debootstrap_mirror = 'http://ftp.debian.org/debian', $hostname = false, $interface = false) { + $vs_name = $legacy ? { true => $name, false => $in_domain ? { '' => $name, default => "${name}.${in_domain}" } } + $vs_hostname = $hostname ? { false => 'none', default => $hostname } case $vs_name { '': { fail ( "Cannot create VServer with empty name" ) } } @@ -116,7 +116,7 @@ define vs_create($in_domain, $context, $legacy = false, $distro = 'etch', } } false: { - exec { "/usr/local/bin/build_vserver \"${vs_name}\" ${context} ${distro} ${debootstrap_mirror}": + exec { "/usr/local/bin/build_vserver \"${vs_name}\" ${context} ${distro} ${debootstrap_mirror} ${vs_hostname} ${interface}": creates => "/etc/vservers/${vs_name}", require => File["/usr/local/bin/build_vserver"], alias => "vs_create_${vs_name}" @@ -126,7 +126,8 @@ define vs_create($in_domain, $context, $legacy = false, $distro = 'etch', } # ensure: present, stopped, running -define vserver($ensure, $context, $in_domain = '', $mark = '', $legacy = false, $distro = 'etch') { +define vserver($ensure, $context, $in_domain = '', $mark = '', $legacy = false, $distro = 'etch', + $hostname = false, $interface = false) { case $in_domain { '': {} default: { err("${fqdn}: vserver ${name} uses deprecated \$in_domain" ) } } @@ -135,21 +136,59 @@ define vserver($ensure, $context, $in_domain = '', $mark = '', $legacy = false, case $vs_name { '': { fail ( "Cannot create VServer with empty name" ) } } - $if_dir = "/etc/vservers/${vs_name}/interfaces" + $if_dir = "/etc/vservers/${vs_name}/interfaces" $mark_file = "/etc/vservers/${vs_name}/apps/init/mark" # TODO: wasn't there a syntax for using arrays as case selectors?? case $ensure { - present: { vs_create{$name: in_domain => $in_domain, context => $context, legacy => $legacy, distro => $distro, } } - running: { vs_create{$name: in_domain => $in_domain, context => $context, legacy => $legacy, distro => $distro, } } - stopped: { vs_create{$name: in_domain => $in_domain, context => $context, legacy => $legacy, distro => $distro, } } - delete: { vs_create{$name: in_domain => $in_domain, context => $context, legacy => $legacy, distro => $distro, } } - default: { err("${fqdn}: vserver(${vs_name}): unknown ensure '${ensure}'") } + present: { + vs_create{ $name: + in_domain => $in_domain, + context => $context, + legacy => $legacy, + distro => $distro, + hostname => $hostname, + interface => $interface, + } + } + running: { + vs_create{ $name: + in_domain => $in_domain, + context => $context, + legacy => $legacy, + distro => $distro, + hostname => $hostname, + interface => $interface, + } + } + stopped: { + vs_create{ $name: + in_domain => $in_domain, + context => $context, + legacy => $legacy, + distro => $distro, + hostname => $hostname, + interface => $interface, + } + } + delete: { + vs_create{ $name: + in_domain => $in_domain, + context => $context, + legacy => $legacy, + distro => $distro, + hostname => $hostname, + interface => $interface, + } + } + default: { + err("${fqdn}: vserver(${vs_name}): unknown ensure '${ensure}'") + } } file { $if_dir: - ensure => directory, checksum => mtime, + ensure => directory, checksum => mtime, require => Exec["vs_create_${vs_name}"]; } |