Skip to content

Commit

Permalink
Merge pull request #236 from simondeziel/maskable-units
Browse files Browse the repository at this point in the history
Link the unit file to /dev/null when "enable => mask"
  • Loading branch information
ekohl authored Dec 23, 2021
2 parents 22b6a16 + aef7754 commit 469b0f2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
10 changes: 8 additions & 2 deletions manifests/unit_file.pp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,13 @@

assert_type(Systemd::Unit, $name)

if $target {
if $enable == 'mask' {
$_target = '/dev/null'
} else {
$_target = $target
}

if $_target {
$_ensure = 'link'
} else {
$_ensure = $ensure ? {
Expand All @@ -80,7 +86,7 @@
ensure => $_ensure,
content => $content,
source => $source,
target => $target,
target => $_target,
owner => $owner,
group => $group,
mode => $mode,
Expand Down
10 changes: 10 additions & 0 deletions spec/defines/unit_file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,16 @@
end
end

context 'enable => mask' do
let(:params) { { enable: 'mask' } }

it do
expect(subject).to create_file("/etc/systemd/system/#{title}").
with_ensure('link').
with_target('/dev/null')
end
end

context 'when using default values for enable and active' do
it {
expect(subject).to create_exec("#{title}-systemctl-daemon-reload").with(
Expand Down

0 comments on commit 469b0f2

Please sign in to comment.