Skip to content

Commit

Permalink
Merge pull request voxpupuli#235 from voxpupuli/modulesync
Browse files Browse the repository at this point in the history
modulesync 5.0.0
  • Loading branch information
bastelfreak committed Oct 31, 2021
2 parents 24271f9 + ecdd76c commit adcf815
Show file tree
Hide file tree
Showing 19 changed files with 154 additions and 75 deletions.
2 changes: 1 addition & 1 deletion .msync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# Managed by modulesync - DO NOT EDIT
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/

modulesync_config_version: '4.2.0'
modulesync_config_version: '5.0.1'
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
source ENV['GEM_SOURCE'] || "https://rubygems.org"

group :test do
gem 'voxpupuli-test', '~> 2.5', :require => false
gem 'voxpupuli-test', '~> 4.0', :require => false
gem 'coveralls', :require => false
gem 'simplecov-console', :require => false
gem 'puppet_metadata', '~> 1.0', :require => false
Expand All @@ -22,7 +22,7 @@ end

group :release do
gem 'github_changelog_generator', '>= 1.16.1', :require => false if RUBY_VERSION >= '2.5'
gem 'voxpupuli-release', '>= 1.0.2', :require => false
gem 'voxpupuli-release', '>= 1.2.0', :require => false
gem 'puppet-strings', '>= 2.2', :require => false
end

Expand Down
2 changes: 2 additions & 0 deletions lib/facter/systemd.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Fact: systemd
#
# Purpose:
Expand Down
2 changes: 2 additions & 0 deletions lib/puppet/provider/loginctl_user/ruby.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# @summary custom provider to manage systemd user sessions/linger
# @see https://www.freedesktop.org/software/systemd/man/loginctl.html
# @see https://wiki.archlinux.org/title/Systemd/User
Expand Down
2 changes: 2 additions & 0 deletions lib/puppet/type/loginctl_user.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'digest/md5'

Puppet::Type.newtype(:loginctl_user) do
Expand Down
85 changes: 56 additions & 29 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'spec_helper'

describe 'systemd' do
Expand Down Expand Up @@ -99,12 +101,14 @@
it { is_expected.to contain_ini_setting('llmnr') }
it { is_expected.to contain_ini_setting('dnssec') }
it { is_expected.to contain_ini_setting('dnsovertls') }

it {
is_expected.to contain_ini_setting('cache').with(
expect(subject).to contain_ini_setting('cache').with(
path: '/etc/systemd/resolved.conf',
value: 'yes'
)
}

it { is_expected.to contain_ini_setting('dns_stub_listener') }
end

Expand All @@ -118,8 +122,9 @@

it { is_expected.to create_service('systemd-resolved').with_ensure('running') }
it { is_expected.to create_service('systemd-resolved').with_enable(true) }

it {
is_expected.to contain_ini_setting('cache').with(
expect(subject).to contain_ini_setting('cache').with(
path: '/etc/systemd/resolved.conf',
value: 'no-negative'
)
Expand Down Expand Up @@ -179,6 +184,7 @@
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_systemd__service_limits('openstack-nova-compute.service').with_limits('LimitNOFILE' => 32_768) }
end

context 'when passing networks' do
let :params do
{
Expand All @@ -193,6 +199,7 @@
it { is_expected.to contain_file('/etc/systemd/network/uplink.netdev') }
it { is_expected.to have_systemd__network_resource_count(2) }
end

context 'when passing timers' do
let :params do
{
Expand All @@ -210,6 +217,7 @@
it { is_expected.to have_systemd__timer_resource_count(2) }
it { is_expected.to have_systemd__unit_file_resource_count(2) }
end

context 'when passing tmpfiles' do
let :params do
{
Expand All @@ -224,6 +232,7 @@
it { is_expected.to contain_file('/etc/tmpfiles.d/second_tmpfile.conf') }
it { is_expected.to have_systemd__tmpfile_resource_count(2) }
end

context 'when passing unit_files' do
let :params do
{
Expand All @@ -238,6 +247,7 @@
it { is_expected.to contain_file('/etc/systemd/system/second.service') }
it { is_expected.to have_systemd__unit_file_resource_count(2) }
end

context 'when managing Accounting options' do
let :params do
{
Expand All @@ -248,61 +258,63 @@
it { is_expected.to contain_class('systemd::system') }

case facts[:os]['family']
when 'Archlinux'
when 'Archlinux', 'Gentoo'
accounting = %w[DefaultCPUAccounting DefaultIOAccounting DefaultIPAccounting DefaultBlockIOAccounting DefaultMemoryAccounting DefaultTasksAccounting]
when 'Debian'
accounting = %w[DefaultCPUAccounting DefaultBlockIOAccounting DefaultMemoryAccounting]
when 'Gentoo'
accounting = %w[DefaultCPUAccounting DefaultIOAccounting DefaultIPAccounting DefaultBlockIOAccounting DefaultMemoryAccounting DefaultTasksAccounting]
when 'RedHat'
accounting = %w[DefaultCPUAccounting DefaultBlockIOAccounting DefaultMemoryAccounting DefaultTasksAccounting]
when 'Suse'
when 'RedHat', 'Suse'
accounting = %w[DefaultCPUAccounting DefaultBlockIOAccounting DefaultMemoryAccounting DefaultTasksAccounting]
end
accounting.each do |account|
it { is_expected.to contain_ini_setting(account) }
end
it { is_expected.to compile.with_all_deps }
end

context 'when enabling journald with options' do
let(:params) do
{
manage_journald: true,
journald_settings: {
'Storage' => 'auto',
'Storage' => 'auto',
'MaxRetentionSec' => '5day',
'MaxLevelStore' => {
'MaxLevelStore' => {
'ensure' => 'absent',
},
},
}
end

it { is_expected.to compile.with_all_deps }

it {
is_expected.to contain_service('systemd-journald').with(
expect(subject).to contain_service('systemd-journald').with(
ensure: 'running'
)
}

it { is_expected.to have_ini_setting_resource_count(3) }

it {
is_expected.to contain_ini_setting('Storage').with(
expect(subject).to contain_ini_setting('Storage').with(
path: '/etc/systemd/journald.conf',
section: 'Journal',
notify: 'Service[systemd-journald]',
value: 'auto'
)
}

it {
is_expected.to contain_ini_setting('MaxRetentionSec').with(
expect(subject).to contain_ini_setting('MaxRetentionSec').with(
path: '/etc/systemd/journald.conf',
section: 'Journal',
notify: 'Service[systemd-journald]',
value: '5day'
)
}

it {
is_expected.to contain_ini_setting('MaxLevelStore').with(
expect(subject).to contain_ini_setting('MaxLevelStore').with(
path: '/etc/systemd/journald.conf',
section: 'Journal',
notify: 'Service[systemd-journald]',
Expand Down Expand Up @@ -348,13 +360,15 @@
end

it { is_expected.to compile.with_all_deps }

it {
is_expected.to contain_service('systemd-udevd').
expect(subject).to contain_service('systemd-udevd').
with(enable: true,
ensure: 'running')
}

it {
is_expected.to contain_file('/etc/udev/udev.conf').
expect(subject).to contain_file('/etc/udev/udev.conf').
with(ensure: 'file',
owner: 'root',
group: 'root',
Expand Down Expand Up @@ -390,13 +404,15 @@
end

it { is_expected.to compile.with_all_deps }

it {
is_expected.to contain_service('systemd-udevd').
expect(subject).to contain_service('systemd-udevd').
with(enable: true,
ensure: 'running')
}

it {
is_expected.to contain_file('/etc/udev/udev.conf').
expect(subject).to contain_file('/etc/udev/udev.conf').
with(ensure: 'file',
owner: 'root',
group: 'root',
Expand All @@ -408,8 +424,9 @@
with_content(%r{^resolve_names=early$}).
with_content(%r{^timeout_signal=SIGKILL$})
}

it {
is_expected.to contain_systemd__udev__rule('example_raw.rules').
expect(subject).to contain_systemd__udev__rule('example_raw.rules').
with(rules: [
'# I am a comment',
'ACTION=="add", KERNEL=="sda", RUN+="/bin/raw /dev/raw/raw1 %N"',
Expand All @@ -423,10 +440,10 @@
{
manage_logind: true,
logind_settings: {
'HandleSuspendKey' => 'ignore',
'HandleSuspendKey' => 'ignore',
'KillUserProcesses' => 'no',
'KillExcludeUsers' => %w[a b],
'RemoveIPC' => {
'KillExcludeUsers' => %w[a b],
'RemoveIPC' => {
'ensure' => 'absent',
},
'UserTasksMax' => '10000',
Expand All @@ -438,60 +455,69 @@
end

it { is_expected.to compile.with_all_deps }

it {
is_expected.to contain_service('systemd-logind').with(
expect(subject).to contain_service('systemd-logind').with(
ensure: 'running'
)
}

it { is_expected.to have_ini_setting_resource_count(5) }

it {
is_expected.to contain_ini_setting('HandleSuspendKey').with(
expect(subject).to contain_ini_setting('HandleSuspendKey').with(
path: '/etc/systemd/logind.conf',
section: 'Login',
notify: 'Service[systemd-logind]',
value: 'ignore'
)
}

it {
is_expected.to contain_ini_setting('KillUserProcesses').with(
expect(subject).to contain_ini_setting('KillUserProcesses').with(
path: '/etc/systemd/logind.conf',
section: 'Login',
notify: 'Service[systemd-logind]',
value: 'no'
)
}

it {
is_expected.to contain_ini_setting('KillExcludeUsers').with(
expect(subject).to contain_ini_setting('KillExcludeUsers').with(
path: '/etc/systemd/logind.conf',
section: 'Login',
notify: 'Service[systemd-logind]',
value: 'a b'
)
}

it {
is_expected.to contain_ini_setting('RemoveIPC').with(
expect(subject).to contain_ini_setting('RemoveIPC').with(
path: '/etc/systemd/logind.conf',
section: 'Login',
notify: 'Service[systemd-logind]',
ensure: 'absent'
)
}

it {
is_expected.to contain_ini_setting('UserTasksMax').with(
expect(subject).to contain_ini_setting('UserTasksMax').with(
path: '/etc/systemd/logind.conf',
section: 'Login',
notify: 'Service[systemd-logind]',
value: '10000'
)
}

it { is_expected.to contain_loginctl_user('foo').with(linger: 'enabled') }
end

context 'when passing dropin_files' do
let(:params) do
{
dropin_files: {
'my-foo.conf' => {
'unit' => 'foo.service',
'unit' => 'foo.service',
'content' => '[Service]\nReadWritePaths=/',
},
},
Expand All @@ -500,6 +526,7 @@

it { is_expected.to contain_systemd__dropin_file('my-foo.conf').with_content('[Service]\nReadWritePaths=/') }
end

context 'with managed networkd directory' do
let :params do
{
Expand Down
2 changes: 2 additions & 0 deletions spec/classes/tmpfiles_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'spec_helper'

describe 'systemd::tmpfiles' do
Expand Down
Loading

0 comments on commit adcf815

Please sign in to comment.