Skip to content

Commit

Permalink
remove systemd::escpae usage for timer_wrapper
Browse files Browse the repository at this point in the history
fixes #451
  • Loading branch information
TheMeier committed Apr 12, 2024
1 parent 45e0953 commit d100996
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 22 deletions.
19 changes: 9 additions & 10 deletions manifests/timer_wrapper.pp
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,8 @@
}

$service_ensure = $ensure ? { 'absent' => false, default => true, }
$unit_name = systemd::escape($title)

systemd::manage_unit { "${unit_name}.service":
systemd::manage_unit { "${title}.service":
ensure => $ensure,
unit_entry => $service_unit_overrides,
service_entry => {
Expand All @@ -86,7 +85,7 @@
'Type' => 'oneshot',
}.filter |$key, $val| { $val =~ NotUndef } + $service_overrides,
}
systemd::manage_unit { "${unit_name}.timer":
systemd::manage_unit { "${title}.timer":
ensure => $ensure,
unit_entry => $timer_unit_overrides,
timer_entry => $_timer_spec + $timer_overrides,
Expand All @@ -95,19 +94,19 @@
},
}

service { "${unit_name}.timer":
service { "${title}.timer":
ensure => $service_ensure,
enable => $service_ensure,
}

if $ensure == 'present' {
Systemd::Manage_unit["${unit_name}.service"]
-> Systemd::Manage_unit["${unit_name}.timer"]
-> Service["${unit_name}.timer"]
Systemd::Manage_unit["${title}.service"]
-> Systemd::Manage_unit["${title}.timer"]
-> Service["${title}.timer"]
} else {
# Ensure the timer is stopped and disabled before the service
Service["${unit_name}.timer"]
-> Systemd::Manage_unit["${unit_name}.timer"]
-> Systemd::Manage_unit["${unit_name}.service"]
Service["${title}.timer"]
-> Systemd::Manage_unit["${title}.timer"]
-> Systemd::Manage_unit["${title}.service"]
}
}
13 changes: 1 addition & 12 deletions spec/defines/timer_wrapper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,7 @@
end

it {
is_expected.to compile
is_expected.to contain_file('/etc/systemd/system/t-i-t-l-e.timer')
is_expected.to contain_systemd__manage_unit('t-i-t-l-e.timer')
is_expected.to contain_systemd__unit_file('t-i-t-l-e.timer')
is_expected.to contain_file('/etc/systemd/system/t-i-t-l-e.service')
is_expected.to contain_systemd__manage_unit('t-i-t-l-e.service')
is_expected.to contain_systemd__unit_file('t-i-t-l-e.service')
is_expected.to contain_service('t-i-t-l-e.timer')
is_expected.to contain_exec('systemd-t-i-t-l-e.service-systemctl-daemon-reload')
is_expected.to contain_exec('systemd-t-i-t-l-e.timer-systemctl-daemon-reload')
is_expected.to contain_Systemd__Daemon_reload('t-i-t-l-e.service')
is_expected.to contain_Systemd__Daemon_reload('t-i-t-l-e.timer')
is_expected.to compile.and_raise_error(%r{expects a match for Systemd::Unit = Pattern})
}
end

Expand Down

0 comments on commit d100996

Please sign in to comment.