Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2493,23 +2493,23 @@ whether the timer and service should be present or absent

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

Data type: `Optional[Systemd::Unit::Service::Exec]`
Data type: `Optional[Variant[Systemd::Unit::Service::Exec,Array[Systemd::Unit::Service::Exec,1]]]`

the ExecStartPre for the systemd service to execute

Default value: `undef`

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

Data type: `Optional[Systemd::Unit::Service::Exec]`
Data type: `Optional[Variant[Systemd::Unit::Service::Exec,Array[Systemd::Unit::Service::Exec,1]]]`

the command for the systemd service to execute

Default value: `undef`

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

Data type: `Optional[Systemd::Unit::Service::Exec]`
Data type: `Optional[Variant[Systemd::Unit::Service::Exec,Array[Systemd::Unit::Service::Exec,1]]]`

the ExecStartPost for the systemd service to execute

Expand Down
30 changes: 15 additions & 15 deletions manifests/timer_wrapper.pp
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,21 @@
# timer_unit_overrides => { 'Description' => 'Very special timer' },
# }
define systemd::timer_wrapper (
Enum['present', 'absent'] $ensure,
Optional[Systemd::Unit::Service::Exec] $pre_command = undef,
Optional[Systemd::Unit::Service::Exec] $command = undef,
Optional[Systemd::Unit::Service::Exec] $post_command = undef,
Optional[String[1]] $user = undef,
Optional[Systemd::Unit::Timespan] $on_active_sec = undef,
Optional[Systemd::Unit::Timespan] $on_boot_sec = undef,
Optional[Systemd::Unit::Timespan] $on_start_up_sec = undef,
Optional[Systemd::Unit::Timespan] $on_unit_active_sec = undef,
Optional[Systemd::Unit::Timespan] $on_unit_inactive_sec = undef,
Optional[Systemd::Unit::Timespan] $on_calendar = undef,
Systemd::Unit::Service $service_overrides = {},
Systemd::Unit::Timer $timer_overrides = {},
Systemd::Unit::Unit $timer_unit_overrides = {},
Systemd::Unit::Unit $service_unit_overrides = {},
Enum['present', 'absent'] $ensure,
Optional[Variant[Systemd::Unit::Service::Exec,Array[Systemd::Unit::Service::Exec,1]]] $pre_command = undef,
Optional[Variant[Systemd::Unit::Service::Exec,Array[Systemd::Unit::Service::Exec,1]]] $command = undef,
Optional[Variant[Systemd::Unit::Service::Exec,Array[Systemd::Unit::Service::Exec,1]]] $post_command = undef,
Comment on lines +42 to +44
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe that's the point where this should go into a custom type alias? :D

in your example you use:

['/usr/bin/echo run this', '/usr/bin/echo and this']

I'm wondering if the array will confuse because because they will actually do:

['/usr/bin/echo', 'run', 'this']

because of the exec resource, which accepts arrays for a single command + parameters.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will write it out as

ExecStart=/usr/bin/echo run this
ExecStart=/usr/bin/echo and this

its not an actual exec

Optional[String[1]] $user = undef,
Optional[Systemd::Unit::Timespan] $on_active_sec = undef,
Optional[Systemd::Unit::Timespan] $on_boot_sec = undef,
Optional[Systemd::Unit::Timespan] $on_start_up_sec = undef,
Optional[Systemd::Unit::Timespan] $on_unit_active_sec = undef,
Optional[Systemd::Unit::Timespan] $on_unit_inactive_sec = undef,
Optional[Systemd::Unit::Timespan] $on_calendar = undef,
Systemd::Unit::Service $service_overrides = {},
Systemd::Unit::Timer $timer_overrides = {},
Systemd::Unit::Unit $timer_unit_overrides = {},
Systemd::Unit::Unit $service_unit_overrides = {},
) {
$_timer_spec = {
'OnActiveSec' => $on_active_sec,
Expand Down
12 changes: 12 additions & 0 deletions spec/defines/timer_wrapper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@
is_expected.to contain_Systemd__Manage_unit("#{title}.timer")
is_expected.to contain_Systemd__Unit_file("#{title}.timer")
end

context 'with two commands' do
let :params do
super().merge({ command: ['/usr/bin/echo run this', '/usr/bin/echo and this'] })
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})
end
end
end

context 'failue when not passing calendar spec' do
Expand Down