Skip to content

Commit

Permalink
systemd::unit_file, Ensure link get's removed on ensure = absent
Browse files Browse the repository at this point in the history
  • Loading branch information
baurmatt committed Jan 22, 2024
1 parent 00915e3 commit e300262
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
5 changes: 4 additions & 1 deletion manifests/unit_file.pp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@
}

if $_target {
$_ensure = 'link'
$_ensure = $ensure ? {
'absent' => 'absent',
default => 'link',
}
} else {
$_ensure = $ensure ? {
'present' => 'file',
Expand Down
14 changes: 14 additions & 0 deletions spec/defines/unit_file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,20 @@
expect(subject).not_to create_systemd__daemon_reload(title)
}
end

context 'with target => "/tmp/service-target" and ensure => absent' do
let(:params) do
{ ensure: 'absent', target: '/tmp/service-target' }
end

it { is_expected.to compile.with_all_deps }

it do
expect(subject).to create_file("/etc/systemd/system/#{title}").
with_ensure('absent').
with_target('/tmp/service-target')
end
end
end
end
end
Expand Down

0 comments on commit e300262

Please sign in to comment.