Skip to content

Commit

Permalink
rubocop: autofix
Browse files Browse the repository at this point in the history
  • Loading branch information
bastelfreak committed Jun 14, 2021
1 parent 064b7d0 commit 57b9db3
Show file tree
Hide file tree
Showing 14 changed files with 140 additions and 142 deletions.
2 changes: 1 addition & 1 deletion lib/facter/systemd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,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|
Expand Down
4 changes: 1 addition & 3 deletions lib/puppet/provider/loginctl_user/ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ def self.instances

def self.prefetch(resources)
instances.each do |prov|
if resources[prov.name]
resources[prov.name].provider = prov
end
resources[prov.name].provider = prov if resources[prov.name]
end
end

Expand Down
102 changes: 51 additions & 51 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
it {
is_expected.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') }
Expand All @@ -120,7 +120,7 @@
it {
is_expected.to contain_ini_setting('cache').with(
path: '/etc/systemd/resolved.conf',
value: 'no-negative',
value: 'no-negative'
)
}
end
Expand Down Expand Up @@ -190,13 +190,13 @@

case facts[:os]['family']
when 'Archlinux'
accounting = ['DefaultCPUAccounting', 'DefaultIOAccounting', 'DefaultIPAccounting', 'DefaultBlockIOAccounting', 'DefaultMemoryAccounting', 'DefaultTasksAccounting']
accounting = %w[DefaultCPUAccounting DefaultIOAccounting DefaultIPAccounting DefaultBlockIOAccounting DefaultMemoryAccounting DefaultTasksAccounting]
when 'Debian'
accounting = ['DefaultCPUAccounting', 'DefaultBlockIOAccounting', 'DefaultMemoryAccounting']
accounting = %w[DefaultCPUAccounting DefaultBlockIOAccounting DefaultMemoryAccounting]
when 'RedHat'
accounting = ['DefaultCPUAccounting', 'DefaultBlockIOAccounting', 'DefaultMemoryAccounting', 'DefaultTasksAccounting']
accounting = %w[DefaultCPUAccounting DefaultBlockIOAccounting DefaultMemoryAccounting DefaultTasksAccounting]
when 'Suse'
accounting = ['DefaultCPUAccounting', 'DefaultBlockIOAccounting', 'DefaultMemoryAccounting', 'DefaultTasksAccounting']
accounting = %w[DefaultCPUAccounting DefaultBlockIOAccounting DefaultMemoryAccounting DefaultTasksAccounting]
end
accounting.each do |account|
it { is_expected.to contain_ini_setting(account) }
Expand All @@ -220,7 +220,7 @@
it { is_expected.to compile.with_all_deps }
it {
is_expected.to contain_service('systemd-journald').with(
ensure: 'running',
ensure: 'running'
)
}
it { is_expected.to have_ini_setting_resource_count(3) }
Expand All @@ -229,23 +229,23 @@
path: '/etc/systemd/journald.conf',
section: 'Journal',
notify: 'Service[systemd-journald]',
value: 'auto',
value: 'auto'
)
}
it {
is_expected.to contain_ini_setting('MaxRetentionSec').with(
path: '/etc/systemd/journald.conf',
section: 'Journal',
notify: 'Service[systemd-journald]',
value: '5day',
value: '5day'
)
}
it {
is_expected.to contain_ini_setting('MaxLevelStore').with(
path: '/etc/systemd/journald.conf',
section: 'Journal',
notify: 'Service[systemd-journald]',
ensure: 'absent',
ensure: 'absent'
)
}
end
Expand Down Expand Up @@ -288,22 +288,22 @@

it { is_expected.to compile.with_all_deps }
it {
is_expected.to contain_service('systemd-udevd')
.with(enable: true,
ensure: 'running')
is_expected.to contain_service('systemd-udevd').
with(enable: true,
ensure: 'running')
}
it {
is_expected.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$})
is_expected.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$})
}
end

Expand All @@ -330,30 +330,30 @@

it { is_expected.to compile.with_all_deps }
it {
is_expected.to contain_service('systemd-udevd')
.with(enable: true,
ensure: 'running')
is_expected.to contain_service('systemd-udevd').
with(enable: true,
ensure: 'running')
}
it {
is_expected.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$})
is_expected.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_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"',
])
is_expected.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"',
])
}
end

Expand All @@ -364,7 +364,7 @@
logind_settings: {
'HandleSuspendKey' => 'ignore',
'KillUserProcesses' => 'no',
'KillExcludeUsers' => ['a', 'b'],
'KillExcludeUsers' => %w[a b],
'RemoveIPC' => {
'ensure' => 'absent',
},
Expand All @@ -379,7 +379,7 @@
it { is_expected.to compile.with_all_deps }
it {
is_expected.to contain_service('systemd-logind').with(
ensure: 'running',
ensure: 'running'
)
}
it { is_expected.to have_ini_setting_resource_count(5) }
Expand All @@ -388,39 +388,39 @@
path: '/etc/systemd/logind.conf',
section: 'Login',
notify: 'Service[systemd-logind]',
value: 'ignore',
value: 'ignore'
)
}
it {
is_expected.to contain_ini_setting('KillUserProcesses').with(
path: '/etc/systemd/logind.conf',
section: 'Login',
notify: 'Service[systemd-logind]',
value: 'no',
value: 'no'
)
}
it {
is_expected.to contain_ini_setting('KillExcludeUsers').with(
path: '/etc/systemd/logind.conf',
section: 'Login',
notify: 'Service[systemd-logind]',
value: 'a b',
value: 'a b'
)
}
it {
is_expected.to contain_ini_setting('RemoveIPC').with(
path: '/etc/systemd/logind.conf',
section: 'Login',
notify: 'Service[systemd-logind]',
ensure: 'absent',
ensure: 'absent'
)
}
it {
is_expected.to contain_ini_setting('UserTasksMax').with(
path: '/etc/systemd/logind.conf',
section: 'Login',
notify: 'Service[systemd-logind]',
value: '10000',
value: '10000'
)
}
it { is_expected.to contain_loginctl_user('foo').with(linger: 'enabled') }
Expand Down
16 changes: 8 additions & 8 deletions spec/defines/dropin_file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
ensure: 'directory',
recurse: 'true',
purge: 'true',
selinux_ignore_defaults: false,
selinux_ignore_defaults: false
)
}

Expand All @@ -31,7 +31,7 @@
ensure: 'file',
content: %r{#{params[:content]}},
mode: '0444',
selinux_ignore_defaults: false,
selinux_ignore_defaults: false
)
}

Expand Down Expand Up @@ -78,19 +78,19 @@
let(:title) { 'test.badtype' }

it {
expect {
expect do
is_expected.to compile.with_all_deps
}.to raise_error(%r{expects a match for Systemd::Dropin})
end.to raise_error(%r{expects a match for Systemd::Dropin})
}
end

context 'with a bad unit type containing a slash' do
let(:title) { 'test/bad.conf' }

it {
expect {
expect do
is_expected.to compile.with_all_deps
}.to raise_error(%r{expects a match for Systemd::Dropin})
end.to raise_error(%r{expects a match for Systemd::Dropin})
}
end

Expand Down Expand Up @@ -120,7 +120,7 @@
is_expected.to create_file("/etc/systemd/system/#{params[:unit]}.d/#{params[:filename]}").with(
ensure: 'file',
content: %r{#{params[:content]}},
mode: '0444',
mode: '0444'
)
}
end
Expand All @@ -136,7 +136,7 @@
it {
is_expected.to create_file("/etc/systemd/system/#{params[:unit]}.d/#{title}").with(
ensure: 'file',
content: sensitive('TEST_CONTENT'),
content: sensitive('TEST_CONTENT')
)
}
end
Expand Down
4 changes: 2 additions & 2 deletions spec/defines/network_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
is_expected.to create_file("/etc/systemd/network/#{title}").with(
ensure: 'file',
content: %r{#{params[:content]}},
mode: '0444',
mode: '0444'
)
}

Expand All @@ -55,7 +55,7 @@
content: %r{#{params[:content]}},
group: 'systemd-network',
mode: '0640',
show_diff: false,
show_diff: false
)
}

Expand Down
38 changes: 19 additions & 19 deletions spec/defines/service_limits_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,23 @@

it { is_expected.to compile.with_all_deps }
it {
is_expected.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{CPUQuota=125%})
.with_content(%r{IODeviceWeight=/dev/weight 10})
.with_content(%r{IODeviceWeight=/dev/weight2 20})
.with_content(%r{IOReadBandwidthMax=/bw/max 10K})
is_expected.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{CPUQuota=125%}).
with_content(%r{IODeviceWeight=/dev/weight 10}).
with_content(%r{IODeviceWeight=/dev/weight2 20}).
with_content(%r{IOReadBandwidthMax=/bw/max 10K})
}
it {
is_expected.to create_exec("restart #{title} because limits").with(
command: "systemctl restart #{title}",
refreshonly: true,
refreshonly: true
)
}
end
Expand All @@ -58,14 +58,14 @@

it { is_expected.to compile.with_all_deps }
it do
is_expected.to create_file("/etc/systemd/system/#{title}.d/90-limits.conf")
.with_ensure('absent')
.that_notifies("Exec[restart #{title} because limits]")
is_expected.to create_file("/etc/systemd/system/#{title}.d/90-limits.conf").
with_ensure('absent').
that_notifies("Exec[restart #{title} because limits]")
end
it do
is_expected.to create_exec("restart #{title} because limits")
.with_command("systemctl restart #{title}")
.with_refreshonly(true)
is_expected.to create_exec("restart #{title} because limits").
with_command("systemctl restart #{title}").
with_refreshonly(true)
end
end
end
Expand Down
Loading

0 comments on commit 57b9db3

Please sign in to comment.