-
-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support reload of instances of systemd --user
This change increased the minimum required Puppet version to 6.24.0 or 7.9.0 [PUP-5704](https://puppet.atlassian.net/browse/PUP-5704) to support arrays to the command attribute of the exec type. Support the calling the `systemd --user daemon-reload` for a particular user. Example run: ```puppet notify{'junk': notify => Systemd::Daemon_reload['user_foobar'], } systemd::daemon_reload{'user_steve': user => 'steve', } ``` This results on a Fedora box: ``` Notice: /Stage[main]/Main/Notify[junk]/message: defined 'message' as 'junk' Notice: /Stage[main]/Main/Systemd::Daemon_reload[user_steve]/Package[systemd-container]: Triggered 'refresh' from 1 event Notice: /Stage[main]/Main/Systemd::Daemon_reload[user_steve]/Exec[systemd-user_steve-systemctl-user-steve-daemon-reload]: Triggered 'refresh' from 1 event ``` and a journal (debug on) for [email protected] of ``` Mar 29 10:32:11 fedora systemd[2062]: Created slice background.slice - User Background Tasks Slice. Mar 29 10:32:11 fedora systemd[2062]: Starting systemd-tmpfiles-clean.service - Cleanup of User's Temporary Files and Directories... Mar 29 10:32:11 fedora systemd[2062]: Reloading requested from client PID 4379 ('systemctl')... Mar 29 10:32:11 fedora systemd[2062]: Reloading... Mar 29 10:32:11 fedora systemd[2062]: Reloading finished in 179 ms. Mar 29 10:32:11 fedora systemd[2062]: Finished systemd-tmpfiles-clean.service - Cleanup of User's Temporary Files and Directories. ... Only recent versions of `systemd-run` support the --machine option or actually manage to connect to DBUS.
- Loading branch information
1 parent
48e0752
commit 0d86eca
Showing
4 changed files
with
109 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,9 +14,39 @@ | |
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) | ||
end | ||
|
||
context 'with a username specfied' do | ||
let(:params) do | ||
{ user: 'steve' } | ||
end | ||
|
||
case [facts[:os]['name'], facts[:os]['family'], facts[:os]['release']['major']] | ||
when %w[Debian Debian 10], | ||
%w[Debian Debian 11], | ||
['Ubuntu', 'Debian', '20.04'], | ||
%w[VirtuozzoLinux RedHat 7], | ||
%w[AlmaLinux RedHat 8], | ||
%w[CentOS RedHat 7], | ||
%w[CentOS RedHat 8], | ||
%w[RedHat RedHat 7], | ||
%w[RedHat RedHat 8], | ||
%w[Rocky RedHat 8], | ||
%w[OracleLinux RedHat 8] | ||
it { is_expected.to compile.and_raise_error(%r{user is not supported below}) } | ||
else | ||
it { is_expected.to compile } | ||
|
||
it { | ||
is_expected.to contain_exec('systemd-irregardless-systemctl-user-steve-daemon-reload'). | ||
with_command(['systemd-run', '--pipe', '--wait', '--user', '--machine', '[email protected]', 'systemctl', '--user', 'daemon-reload']). | ||
with_refreshonly(true) | ||
} | ||
|
||
end | ||
end | ||
end | ||
|
||
context 'when disabled' do | ||
|
@@ -27,6 +57,14 @@ | |
it do | ||
expect(subject).not_to contain_exec("systemd-#{title}-systemctl-daemon-reload") | ||
end | ||
|
||
context 'with a username specfied' do | ||
let(:params) do | ||
super().merge(user: 'steve') | ||
end | ||
|
||
it { is_expected.not_to contain_exec('systemd-irregardless-systemctl-user-steve-daemon-reload') } | ||
end | ||
end | ||
end | ||
end | ||
|