Skip to content

Commit

Permalink
Use arrays for systemctl commands
Browse files Browse the repository at this point in the history
  • Loading branch information
traylenator committed Feb 29, 2024
1 parent e7d5d35 commit 2834d9a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions manifests/daemon_reload.pp
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@
$_title = "${module_name}-${name}-systemctl-user-${uid}-daemon-reload"
$_user = String($uid) # exec seems unhappy with integers.
$_env = "XDG_RUNTIME_DIR=/run/user/${uid}"
$_command = 'systemctl --user daemon-reload'
$_command = ['systemctl', '--user', 'daemon-reload']
} else {
$_title = "${module_name}-${name}-systemctl-daemon-reload"
$_user = undef
$_env = undef
$_command = 'systemctl daemon-reload'
$_command = ['systemctl', 'daemon-reload']
}

exec { $_title:
Expand Down
8 changes: 4 additions & 4 deletions spec/defines/daemon_reload.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
context 'with defaults' do
it do
expect(subject).to contain_exec("systemd-#{title}-systemctl-daemon-reload").
with_command('systemctl daemon-reload').
with_command(%w[systemctl daemon-reload]).
with_refreshonly(true).
without_environment.
without_user
Expand All @@ -31,21 +31,21 @@
end
end

context 'when a uid is specified' do
context 'when a non-zero uid is specified' do
let(:params) do
{ 'uid' => 1234 }
end

it do
expect(subject).to contain_exec("systemd-#{title}-systemctl-user-1234-daemon-reload").
with_command('systemctl --user daemon-reload').
with_command(%w[systemctl --user daemon-reload]).
with_environment('XDG_RUNTIME_DIR=/run/user/1234').
with_user(1234).
with_refreshonly(true)
end
end

context 'when a uid is 0 (root)' do
context 'when the uid is 0 (root)' do
let(:params) do
{ 'uid' => 0 }
end
Expand Down

0 comments on commit 2834d9a

Please sign in to comment.