aboutsummaryrefslogtreecommitdiff
path: root/manifests/vserver/create.pp
diff options
context:
space:
mode:
Diffstat (limited to 'manifests/vserver/create.pp')
-rw-r--r--manifests/vserver/create.pp75
1 files changed, 75 insertions, 0 deletions
diff --git a/manifests/vserver/create.pp b/manifests/vserver/create.pp
new file mode 100644
index 0000000..6a6924b
--- /dev/null
+++ b/manifests/vserver/create.pp
@@ -0,0 +1,75 @@
+define virtual::vserver::create($in_domain, $context, $legacy = false, $distro = 'squeeze',
+ $debootstrap_mirror = 'http://cdn.debian.net/debian',
+ $hostname = false, $interface = false,
+ $memory_limit = false) {
+ $vs_name = $legacy ? { true => $name, false => $in_domain ? { '' => $name, default => "${name}.${in_domain}" } }
+ $vs_hostname = $hostname ? { false => 'none', default => $hostname }
+ $vs_interface = $interface ? { false => 'none', default => $interface }
+
+ case $vs_name { '': { fail ( "Cannot create VServer with empty name" ) } }
+
+ case $legacy {
+ true: {
+ exec { "/bin/false # cannot create legacy vserver ${vs_name}":
+ creates => "/etc/vservers/${vs_name}",
+ alias => "vs_create_${vs_name}"
+ }
+ }
+ false: {
+ exec { "/usr/local/bin/build_vserver \"${vs_name}\" ${context} ${distro} ${debootstrap_mirror} ${vs_hostname} ${vs_interface} ${memory_limit}":
+ creates => "/etc/vservers/${vs_name}",
+ require => File["/usr/local/bin/build_vserver","/etc/vservers/.defaults/vdirbase"],
+ alias => "vs_create_${vs_name}",
+ # TODO: change when this is fixed: http://projects.puppetlabs.com/issues/4769
+ timeout => $lsbdistcodename ? { "squeeze" => '31536000', # 1 year
+ default => '-1', },
+ }
+ }
+ }
+
+ file { "/etc/vservers/${vs_name}/rlimits":
+ ensure => directory,
+ mode => 0755, owner => root, group => root,
+ require => Exec["vs_create_${vs_name}"],
+ }
+
+ case $memory_limit {
+ false: {
+ file { "/etc/vservers/${vs_name}/rlimits/rss.hard":
+ mode => 0644, owner => root, group => root,
+ ensure => absent,
+ }
+
+ file { "/etc/vservers/${vs_name}/rlimits/rss.soft":
+ mode => 0644, owner => root, group => root,
+ ensure => absent,
+ }
+
+ virtual::vserver::flag { "${vs_name}-virt_mem":
+ vserver => $vs_name,
+ flag => "virt_mem",
+ ensure => absent,
+ }
+ }
+ default: {
+ file { "/etc/vservers/${vs_name}/rlimits/rss.hard":
+ mode => 0644, owner => root, group => root,
+ content => template("virtual/rss.hard.erb"),
+ require => File["/etc/vservers/${vs_name}/rlimits"],
+ }
+
+ file { "/etc/vservers/${vs_name}/rlimits/rss.soft":
+ mode => 0644, owner => root, group => root,
+ content => template("virtual/rss.soft.erb"),
+ require => File["/etc/vservers/${vs_name}/rlimits"],
+ }
+
+ virtual::vserver::flag { "${vs_name}-virt_mem":
+ vserver => $vs_name,
+ flag => "virt_mem",
+ ensure => present,
+ require => Exec["vs_create_${vs_name}"],
+ }
+ }
+ }
+}