diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..08c6abf9 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,4 @@ +{ + "name": "VoxBox", + "image": "ghcr.io/voxpupuli/voxbox:latest" +} diff --git a/.msync.yml b/.msync.yml index 81ea369a..7d6d4ee4 100644 --- a/.msync.yml +++ b/.msync.yml @@ -2,4 +2,4 @@ # Managed by modulesync - DO NOT EDIT # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ -modulesync_config_version: '10.4.0' +modulesync_config_version: '10.6.0' diff --git a/.rubocop.yml b/.rubocop.yml index b4c10e57..8c3cf1e2 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,4 +1,6 @@ --- +inherit_from: .rubocop_todo.yml + # Managed by modulesync - DO NOT EDIT # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 00000000..73ab1107 --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,20 @@ +# This configuration was generated by +# `rubocop --auto-gen-config --no-auto-gen-timestamp` +# using RuboCop version 1.85.1. +# The point is for the user to remove these configuration records +# one by one as the offenses are removed from the code base. +# Note that changes in the inspected code, or installation of new +# versions of RuboCop, may require this file to be generated again. + +# Offense count: 4 +RSpec/LeakyLocalVariable: + Exclude: + - 'spec/acceptance/networkd_spec.rb' + - 'spec/acceptance/resolved_spec.rb' + - 'spec/unit/puppet/provider/loginctl_user/ruby_spec.rb' + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/FileNull: + Exclude: + - 'spec/defines/unit_file_spec.rb' diff --git a/Gemfile b/Gemfile index 56259860..e0c85815 100644 --- a/Gemfile +++ b/Gemfile @@ -4,8 +4,8 @@ source ENV['GEM_SOURCE'] || 'https://rubygems.org' group :test do - gem 'voxpupuli-test', '~> 13.0', :require => false - gem 'puppet_metadata', '~> 5.0', :require => false + gem 'voxpupuli-test', '~> 14.0', :require => false + gem 'puppet_metadata', '~> 6.0', :require => false end group :development do @@ -18,7 +18,7 @@ group :system_tests do end group :release do - gem 'voxpupuli-release', '~> 5.0', :require => false + gem 'voxpupuli-release', '~> 5.3', :require => false end gem 'rake', :require => false diff --git a/lib/facter/systemd.rb b/lib/facter/systemd.rb index d6a2db3a..adb0e0c6 100644 --- a/lib/facter/systemd.rb +++ b/lib/facter/systemd.rb @@ -53,7 +53,7 @@ confine systemd: true setcode do command_output = Facter::Util::Resolution.exec( - 'systemctl list-unit-files --no-legend --no-pager "systemd-*" -t service --state=enabled,disabled,enabled-runtime,indirect' + 'systemctl list-unit-files --no-legend --no-pager "systemd-*" -t service --state=enabled,disabled,enabled-runtime,indirect', ) lines = command_output.lines.lazy.map { |line| line.split(%r{\s+}) } lines.each_with_object({}) do |(service, status, *), result| diff --git a/spec/acceptance/nspwan_spec.rb b/spec/acceptance/nspwan_spec.rb index d4ff6477..a3a9d41a 100644 --- a/spec/acceptance/nspwan_spec.rb +++ b/spec/acceptance/nspwan_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper_acceptance' describe 'systemd with manage_nspawn true' do - machinectl = (fact('os.name') == 'Debian') && (fact('os.release.major') == '11') ? '/bin/machinectl' : '/usr/bin/machinectl' + machinectl = ((fact('os.name') == 'Debian') && (fact('os.release.major') == '11')) ? '/bin/machinectl' : '/usr/bin/machinectl' context 'configure nspawn' do let(:manifest) do diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index 07a8875a..2c40ae8b 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -83,7 +83,7 @@ super().merge( speed_meter: true, ipv6_forwarding: true, - use_domains: true + use_domains: true, ) end @@ -96,7 +96,7 @@ is_expected.to contain_ini_setting(setting).with( path: '/etc/systemd/networkd.conf', section: 'Network', - value: 'true' + value: 'true', ).that_notifies('Service[systemd-networkd]') end end @@ -181,7 +181,7 @@ manage_resolved: true, dns: ['8.8.8.8', '8.8.4.4'], fallback_dns: ['2001:4860:4860::8888', '2001:4860:4860::8844'], - dns_stub_listener: 'absent' + dns_stub_listener: 'absent', } end @@ -196,7 +196,7 @@ manage_resolved: true, dns: ['8.8.8.8', '8.8.4.4'], fallback_dns: ['2001:4860:4860::8888', '2001:4860:4860::8844'], - dns_stub_listener_extra: 'absent' + dns_stub_listener_extra: 'absent', } end @@ -235,16 +235,16 @@ it { expect(subject).to contain_ini_setting('cache').with( path: '/etc/systemd/resolved.conf', - value: 'yes' + value: 'yes', ) } it { is_expected.to contain_ini_setting('dns_stub_listener').with_ensure('present') } it { - is_expected.to contain_ini_setting('dns_stub_listener_extra'). - with_value(['192.0.2.1', '2001:db8::1']). - with_ensure('present') + is_expected.to contain_ini_setting('dns_stub_listener_extra') + .with_value(['192.0.2.1', '2001:db8::1']) + .with_ensure('present') } end @@ -262,7 +262,7 @@ it do is_expected.to contain_ini_setting('multicast_dns').with( path: '/etc/systemd/resolved.conf', - value: 'yes' + value: 'yes', ) end @@ -272,14 +272,14 @@ ensure: 'directory', owner: 'root', group: 'root', - mode: '0755' + mode: '0755', ) end it do is_expected.to contain_file('/etc/systemd/resolved.conf.d/00-disable-mdns.conf').with( ensure: 'link', - target: '/dev/null' + target: '/dev/null', ).that_notifies('Service[systemd-resolved]') end end @@ -299,7 +299,7 @@ it { expect(subject).to contain_ini_setting('cache').with( path: '/etc/systemd/resolved.conf', - value: 'no-negative' + value: 'no-negative', ) } end @@ -318,7 +318,7 @@ it { expect(subject).to contain_ini_setting('cache').with( path: '/etc/systemd/resolved.conf', - value: 'no' + value: 'no', ) } end @@ -336,7 +336,7 @@ { ensure: 'present', service_entry: { 'Environment' => 'SYSTEMD_RESOLVED_SYNTHESIZE_HOSTNAME=1' }, - } + }, ) } end @@ -355,7 +355,7 @@ ensure: 'present', unit: 'systemd-resolved.service', service_entry: { 'Environment' => 'SYSTEMD_RESOLVED_SYNTHESIZE_HOSTNAME=0' }, - } + }, ) } end @@ -403,7 +403,7 @@ path: '/etc/systemd/oomd.conf', section: 'OOM', notify: 'Service[systemd-oomd]', - value: '10‰' + value: '10‰', ) } @@ -412,7 +412,7 @@ path: '/etc/systemd/oomd.conf', section: 'OOM', notify: 'Service[systemd-oomd]', - value: '10%' + value: '10%', ) } @@ -421,7 +421,7 @@ path: '/etc/systemd/oomd.conf', section: 'OOM', notify: 'Service[systemd-oomd]', - value: 10 + value: 10, ) } end @@ -513,7 +513,7 @@ context 'when setting rtc-local is true' do let(:params) do { - set_local_rtc: true + set_local_rtc: true, } end @@ -525,7 +525,7 @@ context 'when setting rtc-local is false' do let(:params) do { - set_local_rtc: false + set_local_rtc: false, } end @@ -553,7 +553,7 @@ context 'when passing networks' do let :params do { - networks: { 'uplink.network' => { 'content' => 'foo' }, 'uplink.netdev' => { 'content' => 'bar' }, }, + networks: { 'uplink.network' => { 'content' => 'foo' }, 'uplink.netdev' => { 'content' => 'bar' } }, } end @@ -568,7 +568,7 @@ context 'when passing timers' do let :params do { - timers: { 'first.timer' => { 'timer_content' => 'foo' }, 'second.timer' => { 'timer_content' => 'bar' }, }, + timers: { 'first.timer' => { 'timer_content' => 'foo' }, 'second.timer' => { 'timer_content' => 'bar' } }, } end @@ -586,7 +586,7 @@ context 'when passing tmpfiles' do let :params do { - tmpfiles: { 'first_tmpfile.conf' => { 'content' => 'foo' }, 'second_tmpfile.conf' => { 'content' => 'bar' }, }, + tmpfiles: { 'first_tmpfile.conf' => { 'content' => 'foo' }, 'second_tmpfile.conf' => { 'content' => 'bar' } }, } end @@ -601,7 +601,7 @@ context 'when passing unit_files' do let :params do { - unit_files: { 'first.service' => { 'content' => 'foo' }, 'second.service' => { 'content' => 'bar' }, }, + unit_files: { 'first.service' => { 'content' => 'foo' }, 'second.service' => { 'content' => 'bar' } }, } end @@ -643,7 +643,7 @@ 'DefaultTimeoutStartSec' => '120s', 'DefaultCPUAccounting' => true, 'DefaultMemoryAccounting' => { 'ensure' => 'absent' }, - } + }, ) end @@ -666,7 +666,7 @@ 'DefaultTimeoutStartSec' => '120s', 'DefaultCPUAccounting' => true, 'DefaultMemoryAccounting' => { 'ensure' => 'absent' }, - } + }, } end @@ -678,7 +678,7 @@ is_expected.to contain_ini_setting('system/DefaultTimeoutStartSec').with( ensure: 'present', path: '/etc/systemd/system.conf', - value: '120s' + value: '120s', ) end @@ -686,7 +686,7 @@ is_expected.to contain_ini_setting('system/DefaultCPUAccounting').with( ensure: 'present', path: '/etc/systemd/system.conf', - value: true + value: true, ) end end @@ -699,7 +699,7 @@ 'DefaultTimeoutStartSec' => '123s', 'DefaultLimitCORE' => 'infinity', 'DefaultLimitCPU' => { 'ensure' => 'absent' }, - } + }, } end @@ -711,7 +711,7 @@ is_expected.to contain_ini_setting('user/DefaultTimeoutStartSec').with( ensure: 'present', path: '/etc/systemd/user.conf', - value: '123s' + value: '123s', ) end @@ -719,7 +719,7 @@ is_expected.to contain_ini_setting('user/DefaultLimitCORE').with( ensure: 'present', path: '/etc/systemd/user.conf', - value: 'infinity' + value: 'infinity', ) end end @@ -742,7 +742,7 @@ it { expect(subject).to contain_service('systemd-journald').with( - ensure: 'running' + ensure: 'running', ) } @@ -753,7 +753,7 @@ path: '/etc/systemd/journald.conf', section: 'Journal', notify: 'Service[systemd-journald]', - value: 'auto' + value: 'auto', ) } @@ -762,7 +762,7 @@ path: '/etc/systemd/journald.conf', section: 'Journal', notify: 'Service[systemd-journald]', - value: '5day' + value: '5day', ) } @@ -771,7 +771,7 @@ path: '/etc/systemd/journald.conf', section: 'Journal', notify: 'Service[systemd-journald]', - ensure: 'absent' + ensure: 'absent', ) } end @@ -816,13 +816,13 @@ it { is_expected.to contain_service('systemd-journal-upload').with( ensure: 'running', - enable: true + enable: true, ) } it { is_expected.to contain_service('systemd-journal-remote').with( - ensure: 'running' + ensure: 'running', ) } @@ -834,7 +834,7 @@ section: 'Upload', setting: 'TrustedCertificateFile', notify: 'Service[systemd-journal-upload]', - value: '/tmp/cert-upload.pem' + value: '/tmp/cert-upload.pem', ) } @@ -844,7 +844,7 @@ section: 'Remote', setting: 'TrustedCertificateFile', notify: 'Service[systemd-journal-remote]', - ensure: 'absent' + ensure: 'absent', ) } @@ -854,7 +854,7 @@ section: 'Upload', setting: 'ServerCertificateFile', notify: 'Service[systemd-journal-upload]', - ensure: 'absent' + ensure: 'absent', ) } @@ -864,7 +864,7 @@ section: 'Remote', setting: 'ServerCertificateFile', notify: 'Service[systemd-journal-remote]', - value: '/tmp/cert-remote.pem' + value: '/tmp/cert-remote.pem', ) } end @@ -911,23 +911,23 @@ it { is_expected.to compile.with_all_deps } it { - expect(subject).to contain_service('systemd-udevd'). - with(enable: true, - ensure: 'running') + expect(subject).to contain_service('systemd-udevd') + .with(enable: true, + ensure: 'running') } it { - expect(subject).to contain_file('/etc/udev/udev.conf'). - with(ensure: 'file', - owner: 'root', - group: 'root', - mode: '0444'). - with_content(%r{^udev_log=daemon$}). - with_content(%r{^children_max=1$}). - with_content(%r{^exec_delay=2$}). - with_content(%r{^event_timeout=3$}). - with_content(%r{^resolve_names=early$}). - with_content(%r{^timeout_signal=SIGKILL$}) + expect(subject).to contain_file('/etc/udev/udev.conf') + .with(ensure: 'file', + owner: 'root', + group: 'root', + mode: '0444') + .with_content(%r{^udev_log=daemon$}) + .with_content(%r{^children_max=1$}) + .with_content(%r{^exec_delay=2$}) + .with_content(%r{^event_timeout=3$}) + .with_content(%r{^resolve_names=early$}) + .with_content(%r{^timeout_signal=SIGKILL$}) } it { is_expected.to contain_file('/etc/udev/rules.d').with_ensure('directory').with_purge(false) } @@ -971,32 +971,32 @@ it { is_expected.to compile.with_all_deps } it { - expect(subject).to contain_service('systemd-udevd'). - with(enable: true, - ensure: 'running') + expect(subject).to contain_service('systemd-udevd') + .with(enable: true, + ensure: 'running') } it { - expect(subject).to contain_file('/etc/udev/udev.conf'). - with(ensure: 'file', - owner: 'root', - group: 'root', - mode: '0444'). - with_content(%r{^udev_log=daemon$}). - with_content(%r{^children_max=1$}). - with_content(%r{^exec_delay=2$}). - with_content(%r{^event_timeout=3$}). - with_content(%r{^resolve_names=early$}). - with_content(%r{^timeout_signal=SIGKILL$}) + expect(subject).to contain_file('/etc/udev/udev.conf') + .with(ensure: 'file', + owner: 'root', + group: 'root', + mode: '0444') + .with_content(%r{^udev_log=daemon$}) + .with_content(%r{^children_max=1$}) + .with_content(%r{^exec_delay=2$}) + .with_content(%r{^event_timeout=3$}) + .with_content(%r{^resolve_names=early$}) + .with_content(%r{^timeout_signal=SIGKILL$}) } it { - 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"', - 'ACTION=="add", KERNEL=="sdb", RUN+="/bin/raw /dev/raw/raw2 %N"', - ]) + 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"', + 'ACTION=="add", KERNEL=="sdb", RUN+="/bin/raw /dev/raw/raw2 %N"', + ]) } it { is_expected.to contain_exec('systemd-udev_reload') } @@ -1008,7 +1008,7 @@ { machine_info_settings: { 'PRETTY_HOSTNAME' => 'example hostname', - } + }, } end @@ -1039,7 +1039,7 @@ it { expect(subject).to contain_service('systemd-logind').with( - ensure: 'running' + ensure: 'running', ) } @@ -1050,7 +1050,7 @@ path: '/etc/systemd/logind.conf', section: 'Login', notify: 'Service[systemd-logind]', - value: 'ignore' + value: 'ignore', ) } @@ -1059,7 +1059,7 @@ path: '/etc/systemd/logind.conf', section: 'Login', notify: 'Service[systemd-logind]', - value: 'no' + value: 'no', ) } @@ -1068,7 +1068,7 @@ path: '/etc/systemd/logind.conf', section: 'Login', notify: 'Service[systemd-logind]', - value: 'a b' + value: 'a b', ) } @@ -1077,7 +1077,7 @@ path: '/etc/systemd/logind.conf', section: 'Login', notify: 'Service[systemd-logind]', - ensure: 'absent' + ensure: 'absent', ) } @@ -1086,7 +1086,7 @@ path: '/etc/systemd/logind.conf', section: 'Login', notify: 'Service[systemd-logind]', - value: '10000' + value: '10000', ) } @@ -1122,10 +1122,10 @@ end it { - is_expected.to contain_systemd__manage_unit('special.service'). - with_ensure('present'). - with_unit_entry({ 'Description' => 'My Special Unit' }). - with_service_entry({ 'TimeoutStartSec' => '100h' }) + is_expected.to contain_systemd__manage_unit('special.service') + .with_ensure('present') + .with_unit_entry({ 'Description' => 'My Special Unit' }) + .with_service_entry({ 'TimeoutStartSec' => '100h' }) } end @@ -1147,15 +1147,15 @@ end it { - is_expected.to contain_systemd__manage_dropin('foo.conf'). - with_unit('special.slice'). - with_slice_entry({ 'CPUQuota' => '999%' }) + is_expected.to contain_systemd__manage_dropin('foo.conf') + .with_unit('special.slice') + .with_slice_entry({ 'CPUQuota' => '999%' }) } it { - is_expected.to contain_systemd__manage_dropin('bar.conf'). - with_unit('special.timer'). - with_timer_entry({ 'OnCalendar' => ['', 'Daily'] }) + is_expected.to contain_systemd__manage_dropin('bar.conf') + .with_unit('special.timer') + .with_timer_entry({ 'OnCalendar' => ['', 'Daily'] }) } end @@ -1191,7 +1191,7 @@ 'Storage' => 'none', 'ProcessSizeMax' => '5000E', 'Compress' => 'yes', - } + }, } end @@ -1207,7 +1207,7 @@ section: 'Coredump', setting: 'Storage', value: 'none', - } + }, ) } @@ -1218,7 +1218,7 @@ section: 'Coredump', setting: 'ProcessSizeMax', value: '5000E', - } + }, ) } @@ -1229,7 +1229,7 @@ section: 'Coredump', setting: 'Compress', value: 'yes', - } + }, ) } diff --git a/spec/classes/networkd_spec.rb b/spec/classes/networkd_spec.rb index 64d697e7..1d9d4ff2 100644 --- a/spec/classes/networkd_spec.rb +++ b/spec/classes/networkd_spec.rb @@ -38,8 +38,8 @@ it { is_expected.to compile.with_all_deps } it { - is_expected.to contain_file('/etc/systemd/network/50-static.network'). - with_content(interface_file) + is_expected.to contain_file('/etc/systemd/network/50-static.network') + .with_content(interface_file) } it { diff --git a/spec/classes/sysusers_spec.rb b/spec/classes/sysusers_spec.rb index 99c8d29f..cf2ef7c4 100644 --- a/spec/classes/sysusers_spec.rb +++ b/spec/classes/sysusers_spec.rb @@ -21,7 +21,7 @@ recurse: true, force: true, notify: 'Exec[systemd-sysusers]', - } + }, ) } @@ -42,7 +42,7 @@ purge: false, recurse: false, force: false, - } + }, ) } end diff --git a/spec/defines/daemon_reload_spec.rb b/spec/defines/daemon_reload_spec.rb index 3bd67fa1..6313acdb 100644 --- a/spec/defines/daemon_reload_spec.rb +++ b/spec/defines/daemon_reload_spec.rb @@ -13,9 +13,9 @@ context 'with defaults' do it do - expect(subject).to contain_exec("systemd-#{title}-systemctl-daemon-reload"). - with_command(%w[systemctl daemon-reload]). - with_refreshonly(true) + expect(subject).to contain_exec("systemd-#{title}-systemctl-daemon-reload") + .with_command(%w[systemctl daemon-reload]) + .with_refreshonly(true) end context 'with a username specfied' do @@ -35,9 +35,9 @@ it { is_expected.to compile } it { - is_expected.to contain_exec('systemd-irregardless-systemctl-user-steve-daemon-reload'). - with_command(['run0', '--user', 'steve', '/usr/bin/systemctl', '--user', 'daemon-reload']). - with_refreshonly(true) + is_expected.to contain_exec('systemd-irregardless-systemctl-user-steve-daemon-reload') + .with_command(['run0', '--user', 'steve', '/usr/bin/systemctl', '--user', 'daemon-reload']) + .with_refreshonly(true) } end diff --git a/spec/defines/dropin_file_spec.rb b/spec/defines/dropin_file_spec.rb index c49bc7ae..79e5f4e6 100644 --- a/spec/defines/dropin_file_spec.rb +++ b/spec/defines/dropin_file_spec.rb @@ -24,7 +24,7 @@ ensure: 'directory', recurse: 'true', purge: 'true', - selinux_ignore_defaults: false + selinux_ignore_defaults: false, ) } @@ -37,9 +37,9 @@ ensure: 'file', content: %r{#{params[:content]}}, mode: '0444', - selinux_ignore_defaults: false - ). - that_notifies("Systemd::Daemon_reload[#{params[:unit]}]") + selinux_ignore_defaults: false, + ) + .that_notifies("Systemd::Daemon_reload[#{params[:unit]}]") } context 'notifies services' do @@ -150,7 +150,7 @@ expect(subject).to create_file("/etc/systemd/system/#{params[:unit]}.d/#{params[:filename]}").with( ensure: 'file', content: %r{#{params[:content]}}, - mode: '0444' + mode: '0444', ) } end @@ -167,7 +167,7 @@ it { expect(subject).to create_file("/etc/systemd/system/#{params[:unit]}.d/#{title}").with( ensure: 'file', - content: sensitive('TEST_CONTENT') + content: sensitive('TEST_CONTENT'), ) } end diff --git a/spec/defines/manage_dropin_spec.rb b/spec/defines/manage_dropin_spec.rb index a6d5c5bc..5da9ed6b 100644 --- a/spec/defines/manage_dropin_spec.rb +++ b/spec/defines/manage_dropin_spec.rb @@ -24,17 +24,17 @@ let(:params) do super().merge( unit_entry: {}, - service_entry: {} + service_entry: {}, ) end it { is_expected.to compile.with_all_deps } it { - is_expected.to contain_systemd__dropin_file('foobar.conf'). - with_content(%r{^\[Unit\]$}). - with_content(%r{^\[Service\]$}). - without_content(%r{^\[Slice\]$}) + is_expected.to contain_systemd__dropin_file('foobar.conf') + .with_content(%r{^\[Unit\]$}) + .with_content(%r{^\[Service\]$}) + .without_content(%r{^\[Slice\]$}) } end @@ -42,7 +42,7 @@ let(:params) do super().merge( unit_entry: { - DefaultDependencies: true + DefaultDependencies: true, }, service_entry: { SyslogIdentifier: 'simple', @@ -53,19 +53,19 @@ ['/dev/weight2', 20], ], IOReadBandwidthMax: ['/dev/weight3', '50K'], - } + }, ) end it { - is_expected.to contain_systemd__dropin_file('foobar.conf'). - with_content(%r{^LimitCORE=infinity$}). - with_content(%r{^DefaultDependencies=true$}). - with_content(%r{^SyslogIdentifier=simple$}). - with_content(%r{^IODeviceWeight=/dev/weight 10$}). - with_content(%r{^IODeviceWeight=/dev/weight2 20$}). - with_content(%r{^IOReadBandwidthMax=/dev/weight3 50K$}). - without_content(%r{^\[Slice\]$}) + is_expected.to contain_systemd__dropin_file('foobar.conf') + .with_content(%r{^LimitCORE=infinity$}) + .with_content(%r{^DefaultDependencies=true$}) + .with_content(%r{^SyslogIdentifier=simple$}) + .with_content(%r{^IODeviceWeight=/dev/weight 10$}) + .with_content(%r{^IODeviceWeight=/dev/weight2 20$}) + .with_content(%r{^IOReadBandwidthMax=/dev/weight3 50K$}) + .without_content(%r{^\[Slice\]$}) } end @@ -75,20 +75,20 @@ service_entry: { Type: 'oneshot', ExecStart: ['', '/usr/bin/doit.sh'], - } + }, ) end it { is_expected.to compile.with_all_deps } it { - is_expected.to contain_systemd__dropin_file('foobar.conf'). - with_content(%r{^\[Service\]$}). - without_content(%r{^\[Unit\]$}). - without_content(%r{^\[Install\]$}). - with_content(%r{^ExecStart=$}). - with_content(%r{^ExecStart=/usr/bin/doit.sh$}). - with_content(%r{^Type=oneshot$}) + is_expected.to contain_systemd__dropin_file('foobar.conf') + .with_content(%r{^\[Service\]$}) + .without_content(%r{^\[Unit\]$}) + .without_content(%r{^\[Install\]$}) + .with_content(%r{^ExecStart=$}) + .with_content(%r{^ExecStart=/usr/bin/doit.sh$}) + .with_content(%r{^Type=oneshot$}) } end @@ -98,14 +98,14 @@ unit_entry: { 'After' => ['user-runtime-dir@%i.service'], 'Requires' => ['user-runtime-dir@%i.service'], - } + }, ) end it { - is_expected.to contain_systemd__dropin_file('foobar.conf'). - with_content(%r{^After=user-runtime-dir@%i.service$}). - with_content(%r{^Requires=user-runtime-dir@%i.service$}) + is_expected.to contain_systemd__dropin_file('foobar.conf') + .with_content(%r{^After=user-runtime-dir@%i.service$}) + .with_content(%r{^Requires=user-runtime-dir@%i.service$}) } end @@ -114,7 +114,7 @@ super().merge( timer_entry: { 'OnCalendar' => 'soon', - } + }, ) end @@ -126,7 +126,7 @@ super().merge( slice_entry: { 'MemoryMax' => '100G', - } + }, ) end @@ -140,17 +140,17 @@ unit: 'file.swap', swap_entry: { 'Priority' => 10, - } + }, } end it { is_expected.to compile.with_all_deps } it { - is_expected.to contain_systemd__dropin_file('foobar.conf'). - with_unit('file.swap'). - with_content(%r{^\[Swap\]$}). - with_content(%r{^Priority=10$}) + is_expected.to contain_systemd__dropin_file('foobar.conf') + .with_unit('file.swap') + .with_content(%r{^\[Swap\]$}) + .with_content(%r{^Priority=10$}) } end @@ -160,16 +160,16 @@ unit: 'special.timer', timer_entry: { 'OnCalendar' => 'soon', - } + }, } end it { is_expected.to compile.with_all_deps } it { - is_expected.to contain_systemd__dropin_file('foobar.conf'). - with_unit('special.timer'). - with_content(%r{^OnCalendar=soon$}) + is_expected.to contain_systemd__dropin_file('foobar.conf') + .with_unit('special.timer') + .with_content(%r{^OnCalendar=soon$}) } end @@ -179,16 +179,16 @@ unit: 'var-lib-sss-db.mount', mount_entry: { 'SloppyOptions' => true, - } + }, } end it { is_expected.to compile.with_all_deps } it { - is_expected.to contain_systemd__dropin_file('foobar.conf'). - with_unit('var-lib-sss-db.mount'). - with_content(%r{^SloppyOptions=true$}) + is_expected.to contain_systemd__dropin_file('foobar.conf') + .with_unit('var-lib-sss-db.mount') + .with_content(%r{^SloppyOptions=true$}) } end @@ -202,21 +202,21 @@ 'IOWriteBandwidthMax' => [ ['/dev/afs', '50P'], ['/dev/gluster', 50], - ] - } + ], + }, } end it { is_expected.to compile.with_all_deps } it { - is_expected.to contain_systemd__dropin_file('foobar.conf'). - with_unit('user-.slice'). - with_content(%r{^IOWriteBandwidthMax=/dev/afs 50P$}). - with_content(%r{^IOWriteBandwidthMax=/dev/gluster 50$}). - with_content(%r{^MemoryMax=10G$}). - with_content(%r{^MemoryAccounting=true$}). - without_content(%r{^\[Service\]$}) + is_expected.to contain_systemd__dropin_file('foobar.conf') + .with_unit('user-.slice') + .with_content(%r{^IOWriteBandwidthMax=/dev/afs 50P$}) + .with_content(%r{^IOWriteBandwidthMax=/dev/gluster 50$}) + .with_content(%r{^MemoryMax=10G$}) + .with_content(%r{^MemoryAccounting=true$}) + .without_content(%r{^\[Service\]$}) } end @@ -226,17 +226,17 @@ unit: 'special.path', path_entry: { 'PathExists' => '/etc/hosts', - } + }, } end it { is_expected.to compile.with_all_deps } it { - is_expected.to contain_systemd__dropin_file('foobar.conf'). - with_unit('special.path'). - with_content(%r{^\[Path\]$}). - with_content(%r{^PathExists=/etc/hosts$}) + is_expected.to contain_systemd__dropin_file('foobar.conf') + .with_unit('special.path') + .with_content(%r{^\[Path\]$}) + .with_content(%r{^PathExists=/etc/hosts$}) } end @@ -246,17 +246,17 @@ unit: 'special.socket', socket_entry: { 'ListenMessageQueue' => '/panic', - } + }, } end it { is_expected.to compile.with_all_deps } it { - is_expected.to contain_systemd__dropin_file('foobar.conf'). - with_unit('special.socket'). - with_content(%r{^\[Socket\]$}). - with_content(%r{^ListenMessageQueue=/panic$}) + is_expected.to contain_systemd__dropin_file('foobar.conf') + .with_unit('special.socket') + .with_content(%r{^\[Socket\]$}) + .with_content(%r{^ListenMessageQueue=/panic$}) } end end diff --git a/spec/defines/manage_unit_spec.rb b/spec/defines/manage_unit_spec.rb index 8541df11..a7cd7b89 100644 --- a/spec/defines/manage_unit_spec.rb +++ b/spec/defines/manage_unit_spec.rb @@ -26,26 +26,26 @@ }, install_entry: { WantedBy: 'multi-user.target', - } + }, } end it { is_expected.to compile.with_all_deps } it { - is_expected.to contain_systemd__unit_file('foobar.service'). - with_content(%r{^\[Unit\]$}). - with_content(%r{^DefaultDependencies=true$}). - with_content(%r{^\[Service\]$}). - with_content(%r{^SyslogIdentifier=doit-backwards\.sh$}). - with_content(%r{^Environment=bla=foo$}). - with_content(%r{^Environment=foo=bla$}). - with_content(%r{^\[Install\]$}). - with_content(%r{^Description=My great service$}). - with_content(%r{^Description=has two lines of description$}). - with_content(%r{^Type=oneshot$}). - with_content(%r{^IOReadIOPSMax=/dev/afs 1K$}). - without_content(%r{^\[Slice\]$}) + is_expected.to contain_systemd__unit_file('foobar.service') + .with_content(%r{^\[Unit\]$}) + .with_content(%r{^DefaultDependencies=true$}) + .with_content(%r{^\[Service\]$}) + .with_content(%r{^SyslogIdentifier=doit-backwards\.sh$}) + .with_content(%r{^Environment=bla=foo$}) + .with_content(%r{^Environment=foo=bla$}) + .with_content(%r{^\[Install\]$}) + .with_content(%r{^Description=My great service$}) + .with_content(%r{^Description=has two lines of description$}) + .with_content(%r{^Type=oneshot$}) + .with_content(%r{^IOReadIOPSMax=/dev/afs 1K$}) + .without_content(%r{^\[Slice\]$}) } context 'with no service_entry' do @@ -119,11 +119,11 @@ it { is_expected.to compile.with_all_deps } it { - is_expected.to contain_systemd__unit_file('var-lib-sss-db.mount'). - with_content(%r{^\[Mount\]$}). - with_content(%r{^What=tmpfs$}). - with_content(%r{^Where=/var/lib/sss/db$}). - with_content(%r{^Options=size=300M$}) + is_expected.to contain_systemd__unit_file('var-lib-sss-db.mount') + .with_content(%r{^\[Mount\]$}) + .with_content(%r{^What=tmpfs$}) + .with_content(%r{^Where=/var/lib/sss/db$}) + .with_content(%r{^Options=size=300M$}) } end @@ -141,7 +141,7 @@ it { is_expected.to contain_file('/etc/systemd/system/tmpfs.mount').with( ensure: 'link', - target: '/dev/null' + target: '/dev/null', ) } end @@ -166,12 +166,12 @@ it { is_expected.to compile.with_all_deps } it { - is_expected.to contain_systemd__unit_file('file.swap'). - with_content(%r{^\[Swap\]$}). - with_content(%r{^What=/file$}). - with_content(%r{^TimeoutSec=100$}). - with_content(%r{^Options=trim$}). - with_content(%r{^Priority=10$}) + is_expected.to contain_systemd__unit_file('file.swap') + .with_content(%r{^\[Swap\]$}) + .with_content(%r{^What=/file$}) + .with_content(%r{^TimeoutSec=100$}) + .with_content(%r{^Options=trim$}) + .with_content(%r{^Priority=10$}) } end @@ -196,29 +196,29 @@ 'OnClockChange' => false, 'OnTimezoneChange' => true, 'Unit' => 'summer.service', - } + }, } end it { is_expected.to compile.with_all_deps } it { - is_expected.to contain_systemd__unit_file('winter.timer'). - with_content(%r{^\[Timer\]$}). - with_content(%r{^OnActiveSec=5min$}). - with_content(%r{^OnBootSec=$}). - with_content(%r{^OnBootSec=1min 5s$}). - with_content(%r{^OnStartUpSec=10$}). - with_content(%r{^OnUnitActiveSec=5s$}). - with_content(%r{^OnUnitInactiveSec=$}). - with_content(%r{^OnUnitInactiveSec=10$}). - with_content(%r{^OnCalendar=soon$}). - with_content(%r{^AccuracySec=24h$}). - with_content(%r{^RandomizedDelaySec=4min 20s$}). - with_content(%r{^FixedRandomDelay=true$}). - with_content(%r{^OnClockChange=false$}). - with_content(%r{^OnTimezoneChange=true$}). - with_content(%r{^Unit=summer.service$}) + is_expected.to contain_systemd__unit_file('winter.timer') + .with_content(%r{^\[Timer\]$}) + .with_content(%r{^OnActiveSec=5min$}) + .with_content(%r{^OnBootSec=$}) + .with_content(%r{^OnBootSec=1min 5s$}) + .with_content(%r{^OnStartUpSec=10$}) + .with_content(%r{^OnUnitActiveSec=5s$}) + .with_content(%r{^OnUnitInactiveSec=$}) + .with_content(%r{^OnUnitInactiveSec=10$}) + .with_content(%r{^OnCalendar=soon$}) + .with_content(%r{^AccuracySec=24h$}) + .with_content(%r{^RandomizedDelaySec=4min 20s$}) + .with_content(%r{^FixedRandomDelay=true$}) + .with_content(%r{^OnClockChange=false$}) + .with_content(%r{^OnTimezoneChange=true$}) + .with_content(%r{^Unit=summer.service$}) } end @@ -232,19 +232,19 @@ socket_entry: { 'ListenStream' => 4241, 'Accept' => true, - 'BindIPv6Only' => 'both' - } + 'BindIPv6Only' => 'both', + }, } end it { is_expected.to compile.with_all_deps } it { - is_expected.to contain_systemd__unit_file('arcd.socket'). - with_content(%r{^\[Socket\]$}). - with_content(%r{^ListenStream=4241$}). - with_content(%r{^Accept=true$}). - with_content(%r{^BindIPv6Only=both$}) + is_expected.to contain_systemd__unit_file('arcd.socket') + .with_content(%r{^\[Socket\]$}) + .with_content(%r{^ListenStream=4241$}) + .with_content(%r{^Accept=true$}) + .with_content(%r{^BindIPv6Only=both$}) } end @@ -269,13 +269,13 @@ it { is_expected.to compile.with_all_deps } it { - is_expected.to contain_systemd__unit_file('myslice.slice'). - with_content(%r{^\[Slice\]$}). - with_content(%r{^MemoryMax=10G$}). - with_content(%r{^IOAccounting=true$}). - with_content(%r{^IOWriteIOPSMax=/dev/gluster 20$}). - with_content(%r{^IOWriteIOPSMax=/dev/afs 50K$}). - without_content(%r{^\[Service\]$}) + is_expected.to contain_systemd__unit_file('myslice.slice') + .with_content(%r{^\[Slice\]$}) + .with_content(%r{^MemoryMax=10G$}) + .with_content(%r{^IOAccounting=true$}) + .with_content(%r{^IOWriteIOPSMax=/dev/gluster 20$}) + .with_content(%r{^IOWriteIOPSMax=/dev/afs 50K$}) + .without_content(%r{^\[Service\]$}) } end @@ -298,27 +298,27 @@ 'DirectoryMode' => '0777', 'TriggerLimitIntervalSec' => '10s', 'TriggerLimitBurst' => 100, - } + }, } end it { is_expected.to compile.with_all_deps } it { - is_expected.to contain_systemd__unit_file('etc-passwd.path'). - without_content(%r{^\[Service\]$}). - with_content(%r{^\[Path\]$}). - with_content(%r{^PathExists=/etc/passwd$}). - with_content(%r{^PathExistsGlob=/etc/krb5.conf.d/\*.conf$}). - with_content(%r{^PathChanged=$}). - with_content(%r{^PathModified=$}). - with_content(%r{^PathModified=/etc/httpd/conf.d/\*.conf$}). - with_content(%r{^DirectoryNotEmpty=/tmp$}). - with_content(%r{^Unit=my.service$}). - with_content(%r{^MakeDirectory=true$}). - with_content(%r{^DirectoryMode=0777$}). - with_content(%r{^TriggerLimitIntervalSec=10s$}). - with_content(%r{^TriggerLimitBurst=100$}) + is_expected.to contain_systemd__unit_file('etc-passwd.path') + .without_content(%r{^\[Service\]$}) + .with_content(%r{^\[Path\]$}) + .with_content(%r{^PathExists=/etc/passwd$}) + .with_content(%r{^PathExistsGlob=/etc/krb5.conf.d/\*.conf$}) + .with_content(%r{^PathChanged=$}) + .with_content(%r{^PathModified=$}) + .with_content(%r{^PathModified=/etc/httpd/conf.d/\*.conf$}) + .with_content(%r{^DirectoryNotEmpty=/tmp$}) + .with_content(%r{^Unit=my.service$}) + .with_content(%r{^MakeDirectory=true$}) + .with_content(%r{^DirectoryMode=0777$}) + .with_content(%r{^TriggerLimitIntervalSec=10s$}) + .with_content(%r{^TriggerLimitBurst=100$}) } end end diff --git a/spec/defines/modules_load_spec.rb b/spec/defines/modules_load_spec.rb index e5c21d0f..8d631252 100644 --- a/spec/defines/modules_load_spec.rb +++ b/spec/defines/modules_load_spec.rb @@ -21,7 +21,7 @@ { ensure: 'file', content: 'random stuff', - mode: '0444' + mode: '0444', } } diff --git a/spec/defines/network_spec.rb b/spec/defines/network_spec.rb index b4f3df45..b00b6a56 100644 --- a/spec/defines/network_spec.rb +++ b/spec/defines/network_spec.rb @@ -30,7 +30,7 @@ expect(subject).to create_file("/etc/systemd/network/#{title}").with( ensure: 'file', content: %r{#{params[:content]}}, - mode: '0444' + mode: '0444', ) } @@ -57,7 +57,7 @@ content: %r{#{params[:content]}}, group: 'systemd-network', mode: '0640', - show_diff: false + show_diff: false, ) } @@ -76,7 +76,7 @@ let :params do { content: 'bla', - source: 'foo' + source: 'foo', } end diff --git a/spec/defines/networkd/interface_spec.rb b/spec/defines/networkd/interface_spec.rb index 4240eb52..3dedc231 100644 --- a/spec/defines/networkd/interface_spec.rb +++ b/spec/defines/networkd/interface_spec.rb @@ -58,7 +58,7 @@ Network: { Gateway: '192.168.0.1', }, - } + }, } end @@ -82,8 +82,8 @@ it_behaves_like 'systemd::networkd::interface example' it { - is_expected.to contain_file('/etc/systemd/network/51-static.network'). - with_content(interface_file) + is_expected.to contain_file('/etc/systemd/network/51-static.network') + .with_content(interface_file) } end @@ -109,8 +109,8 @@ VRF: { Table: 42, }, - } - } + }, + }, } end diff --git a/spec/defines/service_limits_spec.rb b/spec/defines/service_limits_spec.rb index 52dd5f69..d7bcbb1f 100644 --- a/spec/defines/service_limits_spec.rb +++ b/spec/defines/service_limits_spec.rb @@ -42,19 +42,19 @@ it { is_expected.to contain_systemd__manage_dropin("#{title}-90-limits.conf").with_ensure('present') } it { - expect(subject).to create_file("/etc/systemd/system/#{title}.d/90-limits.conf"). - with(ensure: 'file', mode: '0444'). - with_content(%r{LimitCPU=10m}). - with_content(%r{LimitFSIZE=infinity}). - with_content(%r{LimitDATA=10K}). - with_content(%r{LimitNOFILE=20:infinity}). - with_content(%r{LimitNICE=-10}). - with_content(%r{LimitRTPRIO=50}). - with_content(%r{MemorySwapMax=0}). - with_content(%r{CPUQuota=125%}). - with_content(%r{IODeviceWeight=/dev/weight 10}). - with_content(%r{IODeviceWeight=/dev/weight2 20}). - with_content(%r{IOReadBandwidthMax=/bw/max 10K}) + expect(subject).to create_file("/etc/systemd/system/#{title}.d/90-limits.conf") + .with(ensure: 'file', mode: '0444') + .with_content(%r{LimitCPU=10m}) + .with_content(%r{LimitFSIZE=infinity}) + .with_content(%r{LimitDATA=10K}) + .with_content(%r{LimitNOFILE=20:infinity}) + .with_content(%r{LimitNICE=-10}) + .with_content(%r{LimitRTPRIO=50}) + .with_content(%r{MemorySwapMax=0}) + .with_content(%r{CPUQuota=125%}) + .with_content(%r{IODeviceWeight=/dev/weight 10}) + .with_content(%r{IODeviceWeight=/dev/weight2 20}) + .with_content(%r{IOReadBandwidthMax=/bw/max 10K}) } describe 'with service managed' do @@ -68,8 +68,8 @@ it { is_expected.to compile.with_all_deps } it do - is_expected.to create_file("/etc/systemd/system/#{title}.d/90-limits.conf"). - that_notifies('Service[test]') + is_expected.to create_file("/etc/systemd/system/#{title}.d/90-limits.conf") + .that_notifies('Service[test]') end end end @@ -87,8 +87,8 @@ it { is_expected.to compile.with_all_deps } it do - expect(subject).to create_file("/etc/systemd/system/#{title}.d/90-limits.conf"). - with_ensure('absent') + expect(subject).to create_file("/etc/systemd/system/#{title}.d/90-limits.conf") + .with_ensure('absent') end end end diff --git a/spec/defines/sysuser_spec.rb b/spec/defines/sysuser_spec.rb index b2f2824c..f1cef746 100644 --- a/spec/defines/sysuser_spec.rb +++ b/spec/defines/sysuser_spec.rb @@ -19,7 +19,7 @@ content: 'random stuff', validate_cmd: '/usr/bin/systemd-sysusers --dry-run %', mode: '0444', - notify: 'Exec[systemd-sysusers]' + notify: 'Exec[systemd-sysusers]', ) } @@ -43,7 +43,7 @@ ensure: 'absent', content: 'random stuff', mode: '0444', - notify: 'Exec[systemd-sysusers]' + notify: 'Exec[systemd-sysusers]', ).without_validate } end @@ -92,7 +92,7 @@ expect(subject).to create_file('/etc/sysusers.d/goodname.conf').with( ensure: 'file', content: 'random stuff', - mode: '0444' + mode: '0444', ) } end diff --git a/spec/defines/timer_spec.rb b/spec/defines/timer_spec.rb index 9e24efb1..21365a23 100644 --- a/spec/defines/timer_spec.rb +++ b/spec/defines/timer_spec.rb @@ -22,13 +22,13 @@ it { expect(subject).to contain_systemd__unit_file('foobar.timer').with( - content: "[Timer]\nOnCalendar=weekly" + content: "[Timer]\nOnCalendar=weekly", ) } it { expect(subject).to contain_systemd__unit_file('foobar.service').with( - content: "[Service]\nExecStart=/bin/touch /tmp/foobar" + content: "[Service]\nExecStart=/bin/touch /tmp/foobar", ).that_comes_before('Systemd::Unit_file[foobar.timer]') } end diff --git a/spec/defines/timer_wrapper_spec.rb b/spec/defines/timer_wrapper_spec.rb index 33b3cd20..bf9fb506 100644 --- a/spec/defines/timer_wrapper_spec.rb +++ b/spec/defines/timer_wrapper_spec.rb @@ -21,19 +21,19 @@ it do is_expected.to compile.with_all_deps - is_expected.to contain_file("/etc/systemd/system/#{title}.service"). - with_content(%r{# Deployed with puppet}). - with_content(%r{Type=oneshot}). - with_content(%r{ExecStart=/bin/date}). - with_content(%r{Type=oneshot}). - with_content(%r{User=root}) - is_expected.to contain_file("/etc/systemd/system/#{title}.timer"). - with_content(%r{OnCalendar=\*:0/10}). - with_content(%r{WantedBy=timers.target}) - is_expected.to contain_Systemd__Unit_file("#{title}.service"). - that_comes_before("Systemd::Unit_file[#{title}.timer]") - is_expected.to contain_Systemd__Unit_file("#{title}.service"). - that_comes_before("Systemd::Unit_file[#{title}.timer]") + is_expected.to contain_file("/etc/systemd/system/#{title}.service") + .with_content(%r{# Deployed with puppet}) + .with_content(%r{Type=oneshot}) + .with_content(%r{ExecStart=/bin/date}) + .with_content(%r{Type=oneshot}) + .with_content(%r{User=root}) + is_expected.to contain_file("/etc/systemd/system/#{title}.timer") + .with_content(%r{OnCalendar=\*:0/10}) + .with_content(%r{WantedBy=timers.target}) + is_expected.to contain_Systemd__Unit_file("#{title}.service") + .that_comes_before("Systemd::Unit_file[#{title}.timer]") + is_expected.to contain_Systemd__Unit_file("#{title}.service") + .that_comes_before("Systemd::Unit_file[#{title}.timer]") is_expected.to contain_Exec("systemd-#{title}.service-systemctl-daemon-reload") is_expected.to contain_Exec("systemd-#{title}.timer-systemctl-daemon-reload") is_expected.to contain_Service("#{title}.timer") @@ -50,9 +50,9 @@ end it do - is_expected.to contain_file("/etc/systemd/system/#{title}.service"). - with_content(%r{ExecStart=/usr/bin/echo run this}). - with_content(%r{ExecStart=/usr/bin/echo and this}) + is_expected.to contain_file("/etc/systemd/system/#{title}.service") + .with_content(%r{ExecStart=/usr/bin/echo run this}) + .with_content(%r{ExecStart=/usr/bin/echo and this}) end end end @@ -97,16 +97,16 @@ end it { - is_expected.to contain_Systemd__Manage_unit("#{title}.timer"). - with_ensure('absent') - is_expected.to contain_Systemd__Manage_unit("#{title}.service"). - with_ensure('absent') - is_expected.to contain_Service("#{title}.timer"). - that_comes_before("Systemd::Unit_file[#{title}.timer]"). - with_ensure(false) - is_expected.to contain_Systemd__Unit_file("#{title}.timer"). - that_comes_before("Systemd::Unit_file[#{title}.service]"). - with_ensure('absent') + is_expected.to contain_Systemd__Manage_unit("#{title}.timer") + .with_ensure('absent') + is_expected.to contain_Systemd__Manage_unit("#{title}.service") + .with_ensure('absent') + is_expected.to contain_Service("#{title}.timer") + .that_comes_before("Systemd::Unit_file[#{title}.timer]") + .with_ensure(false) + is_expected.to contain_Systemd__Unit_file("#{title}.timer") + .that_comes_before("Systemd::Unit_file[#{title}.service]") + .with_ensure('absent') } end @@ -122,8 +122,8 @@ end it { - is_expected.to contain_file("/etc/systemd/system/#{title}.service"). - with_content(%r{Group=bob}) + is_expected.to contain_file("/etc/systemd/system/#{title}.service") + .with_content(%r{Group=bob}) } end @@ -139,8 +139,8 @@ end it { - is_expected.to contain_file("/etc/systemd/system/#{title}.service"). - with_content(%r{Wants=network-online.target}) + is_expected.to contain_file("/etc/systemd/system/#{title}.service") + .with_content(%r{Wants=network-online.target}) } end @@ -156,8 +156,8 @@ end it { - is_expected.to contain_file("/etc/systemd/system/#{title}.timer"). - with_content(%r{OnBootSec=200}) + is_expected.to contain_file("/etc/systemd/system/#{title}.timer") + .with_content(%r{OnBootSec=200}) } end @@ -173,8 +173,8 @@ end it { - is_expected.to contain_file("/etc/systemd/system/#{title}.timer"). - with_content(%r{Wants=network-online.target}) + is_expected.to contain_file("/etc/systemd/system/#{title}.timer") + .with_content(%r{Wants=network-online.target}) } end @@ -190,8 +190,8 @@ end it { - is_expected.to contain_file("/etc/systemd/system/#{title}.service"). - with_content(%r{ExecStartPre=/usr/bin/date}) + is_expected.to contain_file("/etc/systemd/system/#{title}.service") + .with_content(%r{ExecStartPre=/usr/bin/date}) } end @@ -207,8 +207,8 @@ end it { - is_expected.to contain_file("/etc/systemd/system/#{title}.service"). - with_content(%r{ExecStartPost=/usr/bin/date}) + is_expected.to contain_file("/etc/systemd/system/#{title}.service") + .with_content(%r{ExecStartPost=/usr/bin/date}) } end end diff --git a/spec/defines/tmpfile_spec.rb b/spec/defines/tmpfile_spec.rb index defe125c..6c65bb45 100644 --- a/spec/defines/tmpfile_spec.rb +++ b/spec/defines/tmpfile_spec.rb @@ -16,7 +16,7 @@ expect(subject).to create_file("/etc/tmpfiles.d/#{title}").with( ensure: 'file', content: %r{#{params[:content]}}, - mode: '0444' + mode: '0444', ) } @@ -53,7 +53,7 @@ expect(subject).to create_file('/etc/tmpfiles.d/goodname.conf').with( ensure: 'file', content: %r{#{params[:content]}}, - mode: '0444' + mode: '0444', ) } end diff --git a/spec/defines/udev_rules_spec.rb b/spec/defines/udev_rules_spec.rb index 4b37125c..48fc0edf 100644 --- a/spec/defines/udev_rules_spec.rb +++ b/spec/defines/udev_rules_spec.rb @@ -35,13 +35,13 @@ class { 'systemd': manage_udevd => true, manage_journald => false } it { is_expected.to compile.with_all_deps } it { - is_expected.to create_file("/etc/udev/rules.d/#{title}"). - with(ensure: 'file', mode: '0444', owner: 'root', group: 'root'). - with_content(%r{^# This file managed by Puppet - DO NOT EDIT$}). - with_content(%r{^# I am a comment$}). - with_content(%r{^ACTION=="add", KERNEL=="sda", RUN\+="/bin/raw /dev/raw/raw1 %N"$}). - with_content(%r{^ACTION=="add", KERNEL=="sdb", RUN\+="/bin/raw /dev/raw/raw2 %N"$}). - that_notifies('Service[systemd-udevd]') + is_expected.to create_file("/etc/udev/rules.d/#{title}") + .with(ensure: 'file', mode: '0444', owner: 'root', group: 'root') + .with_content(%r{^# This file managed by Puppet - DO NOT EDIT$}) + .with_content(%r{^# I am a comment$}) + .with_content(%r{^ACTION=="add", KERNEL=="sda", RUN\+="/bin/raw /dev/raw/raw1 %N"$}) + .with_content(%r{^ACTION=="add", KERNEL=="sdb", RUN\+="/bin/raw /dev/raw/raw2 %N"$}) + .that_notifies('Service[systemd-udevd]') } it { is_expected.to contain_class('systemd') } @@ -69,19 +69,19 @@ class { 'systemd': manage_udevd => true, manage_journald => false } it { is_expected.to compile.with_all_deps } it { - is_expected.to create_file("/etc/udev/rules.d/#{title}"). - with(ensure: 'file', mode: '0444', owner: 'root', group: 'root'). - with_content(%r{^# This file managed by Puppet - DO NOT EDIT$}). - with_content(%r{^# I am a comment$}). - with_content(%r{^ACTION=="add", KERNEL=="sda", RUN\+="/bin/raw /dev/raw/raw1 %N"$}). - with_content(%r{^ACTION=="add", KERNEL=="sdb", RUN\+="/bin/raw /dev/raw/raw2 %N"$}). - that_notifies('Service[systemd-udevd]'). - that_notifies('Service[foo]') + is_expected.to create_file("/etc/udev/rules.d/#{title}") + .with(ensure: 'file', mode: '0444', owner: 'root', group: 'root') + .with_content(%r{^# This file managed by Puppet - DO NOT EDIT$}) + .with_content(%r{^# I am a comment$}) + .with_content(%r{^ACTION=="add", KERNEL=="sda", RUN\+="/bin/raw /dev/raw/raw1 %N"$}) + .with_content(%r{^ACTION=="add", KERNEL=="sdb", RUN\+="/bin/raw /dev/raw/raw2 %N"$}) + .that_notifies('Service[systemd-udevd]') + .that_notifies('Service[foo]') } end describe 'ensured absent without notify' do - let(:params) { { ensure: 'absent', } } + let(:params) { { ensure: 'absent' } } it { is_expected.to compile.with_all_deps } @@ -106,14 +106,14 @@ class { 'systemd': manage_udevd => true, manage_journald => false, udev_reload = end describe 'ensured absent with custom notify' do - let(:params) { { ensure: 'absent', notify_services: 'Service[systemd-udevd]', } } + let(:params) { { ensure: 'absent', notify_services: 'Service[systemd-udevd]' } } it { is_expected.to compile.with_all_deps } it do - is_expected.to create_file("/etc/udev/rules.d/#{title}"). - with_ensure('absent'). - that_notifies('Service[systemd-udevd]') + is_expected.to create_file("/etc/udev/rules.d/#{title}") + .with_ensure('absent') + .that_notifies('Service[systemd-udevd]') end end end diff --git a/spec/defines/unit_file_spec.rb b/spec/defines/unit_file_spec.rb index 6c66c0da..01483ce9 100644 --- a/spec/defines/unit_file_spec.rb +++ b/spec/defines/unit_file_spec.rb @@ -18,9 +18,9 @@ end it do - expect(subject).to contain_file("/etc/systemd/system/#{title}"). - with_selinux_ignore_defaults(false). - that_notifies("Systemd::Daemon_reload[#{title}]") + expect(subject).to contain_file("/etc/systemd/system/#{title}") + .with_selinux_ignore_defaults(false) + .that_notifies("Systemd::Daemon_reload[#{title}]") end end @@ -28,8 +28,8 @@ let(:params) { { selinux_ignore_defaults: false } } it do - expect(subject).to contain_file("/etc/systemd/system/#{title}"). - with_selinux_ignore_defaults(false) + expect(subject).to contain_file("/etc/systemd/system/#{title}") + .with_selinux_ignore_defaults(false) end end @@ -37,8 +37,8 @@ let(:params) { { selinux_ignore_defaults: true } } it do - expect(subject).to contain_file("/etc/systemd/system/#{title}"). - with_selinux_ignore_defaults(true) + expect(subject).to contain_file("/etc/systemd/system/#{title}") + .with_selinux_ignore_defaults(true) end end @@ -46,10 +46,10 @@ let(:params) { { content: 'non-sensitive Content' } } it do - expect(subject).to create_file("/etc/systemd/system/#{title}"). - with_ensure('file'). - with_content(params[:content]). - with_mode('0444') + expect(subject).to create_file("/etc/systemd/system/#{title}") + .with_ensure('file') + .with_content(params[:content]) + .with_mode('0444') end end @@ -60,8 +60,8 @@ resource = catalogue.resource("File[/etc/systemd/system/#{title}]") expect(resource[:content]).to eq(params[:content].unwrap) - expect(subject).to contain_file("/etc/systemd/system/#{title}"). - with({ content: sensitive('sensitive Content') }) + expect(subject).to contain_file("/etc/systemd/system/#{title}") + .with({ content: sensitive('sensitive Content') }) end end @@ -81,23 +81,23 @@ let(:params) do super().merge( enable: true, - active: true + active: true, ) end it { is_expected.to compile.with_all_deps } it do - expect(subject).to contain_service('test.service'). - with_ensure(true). - with_enable(true). - with_provider('systemd'). - without_hasstatus. - without_hasrestart. - without_flags. - without_timeout. - that_subscribes_to("File[/etc/systemd/system/#{title}]"). - that_subscribes_to("Systemd::Daemon_reload[#{title}]") + expect(subject).to contain_service('test.service') + .with_ensure(true) + .with_enable(true) + .with_provider('systemd') + .without_hasstatus + .without_hasrestart + .without_flags + .without_timeout + .that_subscribes_to("File[/etc/systemd/system/#{title}]") + .that_subscribes_to("Systemd::Daemon_reload[#{title}]") end end @@ -108,23 +108,23 @@ active: true, service_parameters: { flags: '--awesome', - timeout: 1337 - } + timeout: 1337, + }, ) end it { is_expected.to compile.with_all_deps } it do - expect(subject).to contain_service('test.service'). - with_ensure(true). - with_enable(true). - with_provider('systemd'). - without_hasstatus. - without_hasrestart. - with_flags('--awesome'). - with_timeout(1337). - that_subscribes_to("File[/etc/systemd/system/#{title}]") + expect(subject).to contain_service('test.service') + .with_ensure(true) + .with_enable(true) + .with_provider('systemd') + .without_hasstatus + .without_hasrestart + .with_flags('--awesome') + .with_timeout(1337) + .that_subscribes_to("File[/etc/systemd/system/#{title}]") end end @@ -133,26 +133,26 @@ super().merge( enable: true, active: true, - service_restart: false + service_restart: false, ) end it { is_expected.to compile.with_all_deps } it do - expect(subject).to contain_service('test.service'). - with_ensure(true). - with_enable(true). - with_provider('systemd'). - without_hasstatus. - without_hasrestart. - without_flags. - without_timeout + expect(subject).to contain_service('test.service') + .with_ensure(true) + .with_enable(true) + .with_provider('systemd') + .without_hasstatus + .without_hasrestart + .without_flags + .without_timeout end it do - expect(subject).not_to contain_service('test.service'). - that_subscribes_to("Systemd::Daemon_reload[#{title}]") + expect(subject).not_to contain_service('test.service') + .that_subscribes_to("Systemd::Daemon_reload[#{title}]") end end @@ -175,18 +175,18 @@ let(:params) do super().merge( enable: false, - active: false + active: false, ) end it { is_expected.to compile.with_all_deps } it do - expect(subject).to contain_service('test.service'). - with_ensure(false). - with_enable(false). - with_provider('systemd'). - that_comes_before("File[/etc/systemd/system/#{title}]") + expect(subject).to contain_service('test.service') + .with_ensure(false) + .with_enable(false) + .with_provider('systemd') + .that_comes_before("File[/etc/systemd/system/#{title}]") end end end @@ -195,9 +195,9 @@ let(:params) { { enable: 'mask' } } it do - expect(subject).to create_file("/etc/systemd/system/#{title}"). - with_ensure('link'). - with_target('/dev/null') + expect(subject).to create_file("/etc/systemd/system/#{title}") + .with_ensure('link') + .with_target('/dev/null') end end @@ -221,9 +221,9 @@ it { is_expected.to compile.with_all_deps } it do - expect(subject).to create_file("/etc/systemd/system/#{title}"). - with_ensure('absent'). - with_target('/tmp/service-target') + expect(subject).to create_file("/etc/systemd/system/#{title}") + .with_ensure('absent') + .with_target('/tmp/service-target') end end end diff --git a/spec/defines/user_service_spec.rb b/spec/defines/user_service_spec.rb index c0bc5260..eab4c405 100644 --- a/spec/defines/user_service_spec.rb +++ b/spec/defines/user_service_spec.rb @@ -39,10 +39,10 @@ } it { - is_expected.to contain_exec('Enable user service mine.timer globally'). - with_command(['systemctl', '--global', 'enable', 'mine.timer']). - with_unless([['systemctl', '--global', 'is-enabled', 'mine.timer']]). - without_onlyif + is_expected.to contain_exec('Enable user service mine.timer globally') + .with_command(['systemctl', '--global', 'enable', 'mine.timer']) + .with_unless([['systemctl', '--global', 'is-enabled', 'mine.timer']]) + .without_onlyif } end @@ -52,10 +52,10 @@ end it { - is_expected.to contain_exec('Disable user service mine.timer globally'). - with_command(['systemctl', '--global', 'disable', 'mine.timer']). - without_unless. - with_onlyif([['systemctl', '--global', 'is-enabled', 'mine.timer']]) + is_expected.to contain_exec('Disable user service mine.timer globally') + .with_command(['systemctl', '--global', 'disable', 'mine.timer']) + .without_unless + .with_onlyif([['systemctl', '--global', 'is-enabled', 'mine.timer']]) } end @@ -72,25 +72,25 @@ end it { - is_expected.to contain_exec('Stop user service mine.timer for user steve'). - with_command( - ['run0', '--user', 'steve', '/usr/bin/systemctl', '--user', 'stop', 'mine.timer'] - ). - with_onlyif( - [['run0', '--user', 'steve', '/usr/bin/systemctl', '--user', 'is-active', 'mine.timer']] - ). - without_unless + is_expected.to contain_exec('Stop user service mine.timer for user steve') + .with_command( + ['run0', '--user', 'steve', '/usr/bin/systemctl', '--user', 'stop', 'mine.timer'], + ) + .with_onlyif( + [['run0', '--user', 'steve', '/usr/bin/systemctl', '--user', 'is-active', 'mine.timer']], + ) + .without_unless } it { - is_expected.to contain_exec('Disable user service mine.timer for user steve'). - with_command( - ['run0', '--user', 'steve', '/usr/bin/systemctl', '--user', 'disable', 'mine.timer'] - ). - with_onlyif( - [['run0', '--user', 'steve', '/usr/bin/systemctl', '--user', 'is-enabled', 'mine.timer']] - ). - without_unless + is_expected.to contain_exec('Disable user service mine.timer for user steve') + .with_command( + ['run0', '--user', 'steve', '/usr/bin/systemctl', '--user', 'disable', 'mine.timer'], + ) + .with_onlyif( + [['run0', '--user', 'steve', '/usr/bin/systemctl', '--user', 'is-enabled', 'mine.timer']], + ) + .without_unless } end @@ -100,24 +100,24 @@ end it { - is_expected.to contain_exec('Start user service mine.timer for user steve'). - with_command( - ['run0', '--user', 'steve', '/usr/bin/systemctl', '--user', 'start', 'mine.timer'] - ). - without_onlyif. - with_unless( - [['run0', '--user', 'steve', '/usr/bin/systemctl', '--user', 'is-active', 'mine.timer']] + is_expected.to contain_exec('Start user service mine.timer for user steve') + .with_command( + ['run0', '--user', 'steve', '/usr/bin/systemctl', '--user', 'start', 'mine.timer'], + ) + .without_onlyif + .with_unless( + [['run0', '--user', 'steve', '/usr/bin/systemctl', '--user', 'is-active', 'mine.timer']], ) } it { - is_expected.to contain_exec('Enable user service mine.timer for user steve'). - with_command( - ['run0', '--user', 'steve', '/usr/bin/systemctl', '--user', 'enable', 'mine.timer'] - ). - without_onlif. - with_unless( - [['run0', '--user', 'steve', '/usr/bin/systemctl', '--user', 'is-enabled', 'mine.timer']] + is_expected.to contain_exec('Enable user service mine.timer for user steve') + .with_command( + ['run0', '--user', 'steve', '/usr/bin/systemctl', '--user', 'enable', 'mine.timer'], + ) + .without_onlif + .with_unless( + [['run0', '--user', 'steve', '/usr/bin/systemctl', '--user', 'is-enabled', 'mine.timer']], ) } end diff --git a/spec/functions/systemctl_user_spec.rb b/spec/functions/systemctl_user_spec.rb index 11450db6..ec04a51f 100644 --- a/spec/functions/systemctl_user_spec.rb +++ b/spec/functions/systemctl_user_spec.rb @@ -12,8 +12,8 @@ is_expected.to run.with_params('foo', ['status', 'my.service']).and_return( [ 'runuser', '-u', 'foo', '--', '/usr/bin/bash', '-c', - 'env XDG_RUNTIME_DIR=/run/user/$(id -u) /usr/bin/systemctl --user status my.service' - ] + 'env XDG_RUNTIME_DIR=/run/user/$(id -u) /usr/bin/systemctl --user status my.service', + ], ) } @@ -21,8 +21,8 @@ is_expected.to run.with_params('foo', ['is-enabled', 'my.service']).and_return( [ 'runuser', '-u', 'foo', '--', '/usr/bin/bash', '-c', - 'env XDG_RUNTIME_DIR=/run/user/$(id -u) /usr/bin/systemctl --user is-enabled my.service' - ] + 'env XDG_RUNTIME_DIR=/run/user/$(id -u) /usr/bin/systemctl --user is-enabled my.service', + ], ) } end @@ -36,13 +36,13 @@ context 'with valid input' do it { is_expected.to run.with_params('foo', ['status', 'my.service']).and_return( - ['run0', '--user', 'foo', '/usr/bin/systemctl', '--user', 'status', 'my.service'] + ['run0', '--user', 'foo', '/usr/bin/systemctl', '--user', 'status', 'my.service'], ) } it { is_expected.to run.with_params('foo', ['is-enabled', 'my.service']).and_return( - ['run0', '--user', 'foo', '/usr/bin/systemctl', '--user', 'is-enabled', 'my.service'] + ['run0', '--user', 'foo', '/usr/bin/systemctl', '--user', 'is-enabled', 'my.service'], ) } end diff --git a/spec/type_aliases/system_unit_timespan_spec.rb b/spec/type_aliases/system_unit_timespan_spec.rb index 03fc0d00..913a795a 100644 --- a/spec/type_aliases/system_unit_timespan_spec.rb +++ b/spec/type_aliases/system_unit_timespan_spec.rb @@ -12,7 +12,7 @@ 'daily', '5h 30min', '24hours', - ['', 5, '50s', '5h 30min'] + ['', 5, '50s', '5h 30min'], ].each do |value| it { is_expected.to allow_value(value) } end diff --git a/spec/type_aliases/systemd_coredumpsettings_spec.rb b/spec/type_aliases/systemd_coredumpsettings_spec.rb index 6e9dd65a..fc0f15c2 100644 --- a/spec/type_aliases/systemd_coredumpsettings_spec.rb +++ b/spec/type_aliases/systemd_coredumpsettings_spec.rb @@ -15,7 +15,7 @@ 'JournalSizeMax' => '45T', 'MaxUse' => '1P', 'KeepFree' => '1E', - } + }, ) } @@ -29,7 +29,7 @@ 'JournalSizeMax' => '45', 'MaxUse' => '1', 'KeepFree' => '5', - } + }, ) } diff --git a/spec/type_aliases/systemd_oomdsettings_spec.rb b/spec/type_aliases/systemd_oomdsettings_spec.rb index a89e3c95..54da00d7 100644 --- a/spec/type_aliases/systemd_oomdsettings_spec.rb +++ b/spec/type_aliases/systemd_oomdsettings_spec.rb @@ -9,7 +9,7 @@ 'SwapUsedLimit' => '100%', 'DefaultMemoryPressureLimit' => '0%', 'DefaultMemoryPressureDurationSec' => 0, - } + }, ) } @@ -19,7 +19,7 @@ 'SwapUsedLimit' => '1‰', 'DefaultMemoryPressureLimit' => '100%', 'DefaultMemoryPressureDurationSec' => 100_000_000, - } + }, ) } @@ -29,7 +29,7 @@ 'SwapUsedLimit' => '90‱', 'DefaultMemoryPressureLimit' => '30%', 'DefaultMemoryPressureDurationSec' => 10, - } + }, ) } diff --git a/spec/type_aliases/systemd_servicelimits_spec.rb b/spec/type_aliases/systemd_servicelimits_spec.rb index 7bc07f7b..eeb161da 100644 --- a/spec/type_aliases/systemd_servicelimits_spec.rb +++ b/spec/type_aliases/systemd_servicelimits_spec.rb @@ -15,7 +15,7 @@ 'MemoryHigh' => '8G', 'MemoryMax' => 'infinity', 'MemorySwapMax' => '1T', - } + }, ) } diff --git a/spec/type_aliases/systemd_unit_path_spec.rb b/spec/type_aliases/systemd_unit_path_spec.rb index 23e3bc14..28b231f8 100644 --- a/spec/type_aliases/systemd_unit_path_spec.rb +++ b/spec/type_aliases/systemd_unit_path_spec.rb @@ -41,7 +41,7 @@ %w[TriggerLimitIntervalSec].each do |assert| context "with a key of #{assert} can have value of a time period" do - it { is_expected.to allow_value({ assert => '' }) } # ? Not sure actually + it { is_expected.to allow_value({ assert => '' }) } # ? Not sure actually it { is_expected.to allow_value({ assert => '24hours' }) } it { is_expected.to allow_value({ assert => '1min 30s' }) } it { is_expected.not_to allow_value({ assert => ['', '1min 30s'] }) } diff --git a/spec/type_aliases/systemd_unit_service_spec.rb b/spec/type_aliases/systemd_unit_service_spec.rb index 3abcbfa4..ff48d471 100644 --- a/spec/type_aliases/systemd_unit_service_spec.rb +++ b/spec/type_aliases/systemd_unit_service_spec.rb @@ -104,7 +104,7 @@ 'MemoryHigh' => '8G', 'MemoryMax' => 'infinity', 'MemorySwapMax' => '1T', - } + }, ) } diff --git a/spec/type_aliases/systemd_unit_slice_spec.rb b/spec/type_aliases/systemd_unit_slice_spec.rb index dc58f9aa..22686310 100644 --- a/spec/type_aliases/systemd_unit_slice_spec.rb +++ b/spec/type_aliases/systemd_unit_slice_spec.rb @@ -32,7 +32,7 @@ 'MemoryHigh' => '8G', 'MemoryMax' => 'infinity', 'MemorySwapMax' => '1T', - } + }, ) } diff --git a/spec/unit/puppet/provider/loginctl_user/ruby_spec.rb b/spec/unit/puppet/provider/loginctl_user/ruby_spec.rb index c9091d48..58ebb4cb 100644 --- a/spec/unit/puppet/provider/loginctl_user/ruby_spec.rb +++ b/spec/unit/puppet/provider/loginctl_user/ruby_spec.rb @@ -15,12 +15,12 @@ context 'when listing instances' do it 'finds all entries' do - allow(provider_class).to receive(:loginctl). - with('list-users', '--no-legend'). - and_return("0 root\n42 foo\n314 bar\n") - allow(provider_class).to receive(:loginctl). - with('show-user', '-p', 'Name', '-p', 'Linger', 'root', 'foo', 'bar'). - and_return("Name=root\nLinger=no\n\nName=foo\nLinger=yes\n\nName=bar\nLinger=no\n") + allow(provider_class).to receive(:loginctl) + .with('list-users', '--no-legend') + .and_return("0 root\n42 foo\n314 bar\n") + allow(provider_class).to receive(:loginctl) + .with('show-user', '-p', 'Name', '-p', 'Linger', 'root', 'foo', 'bar') + .and_return("Name=root\nLinger=no\n\nName=foo\nLinger=yes\n\nName=bar\nLinger=no\n") inst = provider_class.instances.map! expect(inst.size).to eq(3)