diff options
-rw-r--r-- | manifests/vserver.pp | 80 | ||||
-rw-r--r-- | templates/rss.hard.erb | 1 | ||||
-rw-r--r-- | templates/rss.soft.erb | 1 |
3 files changed, 55 insertions, 27 deletions
diff --git a/manifests/vserver.pp b/manifests/vserver.pp index b7d2c98..55e6841 100644 --- a/manifests/vserver.pp +++ b/manifests/vserver.pp @@ -116,7 +116,9 @@ class vserver::host { } define vs_create($in_domain, $context, $legacy = false, $distro = 'etch', - $debootstrap_mirror = 'http://ftp.debian.org/debian', $hostname = false, $interface = false) { + $debootstrap_mirror = 'http://ftp.debian.org/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 } @@ -131,7 +133,7 @@ define vs_create($in_domain, $context, $legacy = false, $distro = 'etch', } } false: { - exec { "/usr/local/bin/build_vserver \"${vs_name}\" ${context} ${distro} ${debootstrap_mirror} ${vs_hostname} ${vs_interface}": + 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"], alias => "vs_create_${vs_name}", @@ -139,11 +141,31 @@ define vs_create($in_domain, $context, $legacy = false, $distro = 'etch', } } } + + case $memory_limit { + false: { } + default: { + file { "/etc/vservers/${vs_name}/rlimits": + ensure => directory, + mode => 0755, owner => root, group => root, + } + 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'], + } + } + } } # ensure: present, stopped, running define vserver($ensure, $context, $in_domain = '', $mark = '', $legacy = false, $distro = 'etch', - $hostname = false, $interface = false) { + $hostname = false, $interface = false, $memory_limit = false) { case $in_domain { '': {} default: { err("${fqdn}: vserver ${name} uses deprecated \$in_domain" ) } } @@ -160,42 +182,46 @@ define vserver($ensure, $context, $in_domain = '', $mark = '', $legacy = false, case $ensure { present: { vs_create{ $name: - in_domain => $in_domain, - context => $context, - legacy => $legacy, - distro => $distro, - hostname => $hostname, - interface => $interface, + in_domain => $in_domain, + context => $context, + legacy => $legacy, + distro => $distro, + hostname => $hostname, + interface => $interface, + memory_limit => $memory_limit, } } running: { vs_create{ $name: - in_domain => $in_domain, - context => $context, - legacy => $legacy, - distro => $distro, - hostname => $hostname, - interface => $interface, + in_domain => $in_domain, + context => $context, + legacy => $legacy, + distro => $distro, + hostname => $hostname, + interface => $interface, + memory_limit => $memory_limit, } } stopped: { vs_create{ $name: - in_domain => $in_domain, - context => $context, - legacy => $legacy, - distro => $distro, - hostname => $hostname, - interface => $interface, + in_domain => $in_domain, + context => $context, + legacy => $legacy, + distro => $distro, + hostname => $hostname, + interface => $interface, + memory_limit => $memory_limit, } } delete: { vs_create{ $name: - in_domain => $in_domain, - context => $context, - legacy => $legacy, - distro => $distro, - hostname => $hostname, - interface => $interface, + in_domain => $in_domain, + context => $context, + legacy => $legacy, + distro => $distro, + hostname => $hostname, + interface => $interface, + memory_limit => $memory_limit, } } default: { diff --git a/templates/rss.hard.erb b/templates/rss.hard.erb new file mode 100644 index 0000000..f806702 --- /dev/null +++ b/templates/rss.hard.erb @@ -0,0 +1 @@ +<%= memory_limit * 1_000_000 / 4096 %> diff --git a/templates/rss.soft.erb b/templates/rss.soft.erb new file mode 100644 index 0000000..f806702 --- /dev/null +++ b/templates/rss.soft.erb @@ -0,0 +1 @@ +<%= memory_limit * 1_000_000 / 4096 %> |