Gitlab Community Edition Instance

Skip to content
Snippets Groups Projects
Commit b5a50e7a authored by Benedikt Wegmann's avatar Benedikt Wegmann
Browse files

zram

parent c6db02f5
No related branches found
No related tags found
No related merge requests found
......@@ -136,3 +136,9 @@ Installiert das Apt-Modul für automatische Updates. Die Konfiguration installie
* $autoremove (optional) = Entfernt nicht mehr benötigte Pakete, z.B. alte Kernel. (Default: ```true```)
* $allowed_origins (optional) = Array mit Quellenangaben für Apt, aus denen Updates installiert werden dürfen. (Default: ```["\${distro_id}:\${distro_codename}-updates","LP-PPA-ubuntu-lxc-lxd-stable:\${distro_codename}","Docker:ubuntu-\${distro_codename}","Puppetlabs:\${distro_codename}"]```)
* $package_blacklist (optional) = ein Array mit Paketnamen, die von automatischen Updates ausgeschlossen werden. (Default: 'docker-engine')
### ubuntu_server::zram
Installiert `zram-config` Paket zur Einrichtung von komprimierten Blockdevices im RAM ([zram](https://en.wikipedia.org/wiki/Zram)) und mit aktiviertem Swap darauf.
* $agressive (optional) = Setzt die Gesamtgröße der `zram`-Devices auf fast den gesamten RAM statt auf die Hälfte und setzt `vm.swappiness` auf 90 für frühzeitiges auslagern. (Default: `false`)
\ No newline at end of file
vm.swappiness=90
#!/bin/sh
# load dependency modules
NRDEVICES=$(grep -c ^processor /proc/cpuinfo | sed 's/^0$/1/')
if modinfo zram | grep -q ' zram_num_devices:' 2>/dev/null; then
MODPROBE_ARGS="zram_num_devices=${NRDEVICES}"
elif modinfo zram | grep -q ' num_devices:' 2>/dev/null; then
MODPROBE_ARGS="num_devices=${NRDEVICES}"
else
exit 1
fi
modprobe zram $MODPROBE_ARGS
# Calculate memory to use for zram (1/2 of ram)
totalmem=`LC_ALL=C free | grep -e "^Mem:" | sed -e 's/^Mem: *//' -e 's/ *.*//'`
mem=$((((totalmem - 102400 )/ ${NRDEVICES}) * 1024))
# initialize the devices
for i in $(seq ${NRDEVICES}); do
DEVNUMBER=$((i - 1))
echo $mem > /sys/block/zram${DEVNUMBER}/disksize
mkswap /dev/zram${DEVNUMBER}
swapon -p 5 /dev/zram${DEVNUMBER}
done
# zram installieren und ggf. swappiness anpassen
class ubuntu_server::zram($agressive=false){
File{
owner => 'root',
}
package{'zram-config':
ensure => present,
}
if ( $agressive == true ) {
file{'/usr/bin/init-zram-swapping':
ensure => present,
source => 'puppet:///modules/ubuntu_server/usr/bin/init-zram-swapping',
mode => '0755',
require => Package['zram-config'],
}
file{'/etc/sysctl.d/60-swappiness.conf':
ensure => present,
source => 'puppet:///modules/ubuntu_server/etc/sysctl.d/60-swappiness.conf',
}
}
}
require 'spec_helper'
describe "ubuntu_server::zram" do
context "with class defaults" do
it { is_expected.to compile.with_all_deps }
it { is_expected.not_to contain_file('/usr/bin/init-zram-swapping') }
it { is_expected.not_to contain_file('/etc/sysctl.d/60-swappiness.conf') }
end
context "with $agressive = true" do
let(:params) {{
:agressive => true,
}}
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_file('/usr/bin/init-zram-swapping') }
it { is_expected.to contain_file('/etc/sysctl.d/60-swappiness.conf') }
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment