Skip to content

Commit 19c0ee5

Browse files
authored
Merge pull request #595 from traylenator/multiexec
Let timer_wrapper support a list of commands
2 parents 7e69d6a + b91a861 commit 19c0ee5

File tree

3 files changed

+30
-18
lines changed

3 files changed

+30
-18
lines changed

REFERENCE.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2493,23 +2493,23 @@ whether the timer and service should be present or absent
24932493

24942494
##### <a name="-systemd--timer_wrapper--pre_command"></a>`pre_command`
24952495

2496-
Data type: `Optional[Systemd::Unit::Service::Exec]`
2496+
Data type: `Optional[Variant[Systemd::Unit::Service::Exec,Array[Systemd::Unit::Service::Exec,1]]]`
24972497

24982498
the ExecStartPre for the systemd service to execute
24992499

25002500
Default value: `undef`
25012501

25022502
##### <a name="-systemd--timer_wrapper--command"></a>`command`
25032503

2504-
Data type: `Optional[Systemd::Unit::Service::Exec]`
2504+
Data type: `Optional[Variant[Systemd::Unit::Service::Exec,Array[Systemd::Unit::Service::Exec,1]]]`
25052505

25062506
the command for the systemd service to execute
25072507

25082508
Default value: `undef`
25092509

25102510
##### <a name="-systemd--timer_wrapper--post_command"></a>`post_command`
25112511

2512-
Data type: `Optional[Systemd::Unit::Service::Exec]`
2512+
Data type: `Optional[Variant[Systemd::Unit::Service::Exec,Array[Systemd::Unit::Service::Exec,1]]]`
25132513

25142514
the ExecStartPost for the systemd service to execute
25152515

manifests/timer_wrapper.pp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,21 @@
3838
# timer_unit_overrides => { 'Description' => 'Very special timer' },
3939
# }
4040
define systemd::timer_wrapper (
41-
Enum['present', 'absent'] $ensure,
42-
Optional[Systemd::Unit::Service::Exec] $pre_command = undef,
43-
Optional[Systemd::Unit::Service::Exec] $command = undef,
44-
Optional[Systemd::Unit::Service::Exec] $post_command = undef,
45-
Optional[String[1]] $user = undef,
46-
Optional[Systemd::Unit::Timespan] $on_active_sec = undef,
47-
Optional[Systemd::Unit::Timespan] $on_boot_sec = undef,
48-
Optional[Systemd::Unit::Timespan] $on_start_up_sec = undef,
49-
Optional[Systemd::Unit::Timespan] $on_unit_active_sec = undef,
50-
Optional[Systemd::Unit::Timespan] $on_unit_inactive_sec = undef,
51-
Optional[Systemd::Unit::Timespan] $on_calendar = undef,
52-
Systemd::Unit::Service $service_overrides = {},
53-
Systemd::Unit::Timer $timer_overrides = {},
54-
Systemd::Unit::Unit $timer_unit_overrides = {},
55-
Systemd::Unit::Unit $service_unit_overrides = {},
41+
Enum['present', 'absent'] $ensure,
42+
Optional[Variant[Systemd::Unit::Service::Exec,Array[Systemd::Unit::Service::Exec,1]]] $pre_command = undef,
43+
Optional[Variant[Systemd::Unit::Service::Exec,Array[Systemd::Unit::Service::Exec,1]]] $command = undef,
44+
Optional[Variant[Systemd::Unit::Service::Exec,Array[Systemd::Unit::Service::Exec,1]]] $post_command = undef,
45+
Optional[String[1]] $user = undef,
46+
Optional[Systemd::Unit::Timespan] $on_active_sec = undef,
47+
Optional[Systemd::Unit::Timespan] $on_boot_sec = undef,
48+
Optional[Systemd::Unit::Timespan] $on_start_up_sec = undef,
49+
Optional[Systemd::Unit::Timespan] $on_unit_active_sec = undef,
50+
Optional[Systemd::Unit::Timespan] $on_unit_inactive_sec = undef,
51+
Optional[Systemd::Unit::Timespan] $on_calendar = undef,
52+
Systemd::Unit::Service $service_overrides = {},
53+
Systemd::Unit::Timer $timer_overrides = {},
54+
Systemd::Unit::Unit $timer_unit_overrides = {},
55+
Systemd::Unit::Unit $service_unit_overrides = {},
5656
) {
5757
$_timer_spec = {
5858
'OnActiveSec' => $on_active_sec,

spec/defines/timer_wrapper_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,18 @@
4343
is_expected.to contain_Systemd__Manage_unit("#{title}.timer")
4444
is_expected.to contain_Systemd__Unit_file("#{title}.timer")
4545
end
46+
47+
context 'with two commands' do
48+
let :params do
49+
super().merge({ command: ['/usr/bin/echo run this', '/usr/bin/echo and this'] })
50+
end
51+
52+
it do
53+
is_expected.to contain_file("/etc/systemd/system/#{title}.service").
54+
with_content(%r{ExecStart=/usr/bin/echo run this}).
55+
with_content(%r{ExecStart=/usr/bin/echo and this})
56+
end
57+
end
4658
end
4759

4860
context 'failue when not passing calendar spec' do

0 commit comments

Comments
 (0)