Gitlab Community Edition Instance

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

zram: swapfile für >=16.04

parent 72e686e2
No related branches found
No related tags found
No related merge requests found
[Unit]
Description=swapfile anlegen als Unterstützung für zram
[Service]
Type=oneshot
ExecStart=/usr/local/bin/swapfile
[Install]
WantedBy=multi-user.target
#!/bin/bash
# swapfile.conf
#
# swapfile anlegen als Unterstützung für zram
swapfile=/swapfile
mbcount=512
if [ ! -w $swapfile ]; then
dd if=/dev/zero of=$swapfile bs=1M count=$mbcount
fi
if ! fuser -u -v $swapfile ; then
chmod -v 0600 $swapfile
mkswap $swapfile
swapon -v $swapfile
fi
......@@ -34,15 +34,36 @@ class ubuntu_server::zram($agressive=false,$swapfile=false){
}
if ( $swapfile == true ) {
file{'/etc/init/swapfile.conf':
ensure => present,
source => 'puppet:///modules/ubuntu_server/etc/init/swapfile.conf',
mode => '0644',
} ~> Exec['start_swapfile']
exec{'start_swapfile':
path => $::path,
command => 'start swapfile',
refreshonly => true,
if versioncmp($::operatingsystemrelease, '16.04') >= 0 {
file{['/usr/local/bin/','/usr/local/']:
ensure => directory,
}
file{'/etc/systemd/system/swapfile.service':
ensure => present,
source => 'puppet:///modules/ubuntu_server/etc/systemd/system/swapfile.service',
mode => '0644',
} ~> Exec['load_swapfile_service']
file{'/usr/local/bin/swapfile':
ensure => present,
source => 'puppet:///modules/ubuntu_server/usr/local/bin/swapfile',
mode => '0744',
} ~> Exec['load_swapfile_service']
exec{'load_swapfile_service':
path => $::path,
command => 'systemctl daemon-reload; systemctl enable swapfile; systemctl start swapfile',
refreshonly => true,
}
} else {
file{'/etc/init/swapfile.conf':
ensure => present,
source => 'puppet:///modules/ubuntu_server/etc/init/swapfile.conf',
mode => '0644',
} ~> Exec['start_swapfile']
exec{'start_swapfile':
path => $::path,
command => 'start swapfile',
refreshonly => true,
}
}
}
......
......@@ -33,6 +33,8 @@ describe "ubuntu_server::zram" do
it { is_expected.not_to contain_file('/usr/bin/init-zram-swapping') }
it { is_expected.to contain_file('/etc/sysctl.d/60-swappiness.conf') }
it { is_expected.to contain_file('/etc/init/zram-config.conf') }
it { is_expected.not_to contain_file('/etc/systemd/system/swapfile.service') }
it { is_expected.not_to contain_file('/usr/local/bin/swapfile') }
end
context "with $agressive = true and operatingsystemrelease = 16.04" do
......@@ -45,7 +47,11 @@ describe "ubuntu_server::zram" do
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') }
it { is_expected.not_to contain_file('/etc/systemd/system/swapfile.service') }
it { is_expected.not_to contain_file('/usr/local/bin/swapfile') }
it { is_expected.not_to contain_file('/etc/init/zram-config.conf') }
it { is_expected.not_to contain_file('/etc/init/swapfile.conf') }
it { is_expected.not_to contain_exec('start_swapfilefile') }
end
context "with $swapfile = true" do
......@@ -62,4 +68,23 @@ describe "ubuntu_server::zram" do
it { is_expected.to contain_file('/etc/init/swapfile.conf') }
end
context "with $swapfile = true and operatingsystemrelease = 16.04" do
let(:facts) {{
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
:operatingsystemrelease => '16.04',
}}
let(:params) {{
:swapfile => true,
}}
it { is_expected.to contain_file('/etc/systemd/system/swapfile.service') }
it { is_expected.to contain_file('/usr/local/bin/swapfile') }
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') }
it { is_expected.not_to contain_file('/etc/init/zram-config.conf') }
it { is_expected.not_to contain_file('/etc/init/swapfile.conf') }
it { is_expected.not_to contain_file('/etc/init/swapfile.conf') }
it { is_expected.not_to contain_exec('start_swapfilefile') }
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