Skip to content

Commit 037c7a1

Browse files
authored
Merge pull request #606 from bwitt/fix-mask
Fix `systemd::manage_unit` when `enable => 'mask'`
2 parents 14155da + 2c52580 commit 037c7a1

2 files changed

Lines changed: 25 additions & 2 deletions

File tree

manifests/unit_file.pp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,12 @@
9292

9393
if $enable == 'mask' {
9494
$_target = '/dev/null'
95+
$_content = undef
96+
$_source = undef
9597
} else {
9698
$_target = $target
99+
$_content = $content
100+
$_source = $source
97101
}
98102

99103
if $_target {
@@ -104,8 +108,8 @@
104108

105109
file { "${path}/${name}":
106110
ensure => $_ensure,
107-
content => $content,
108-
source => $source,
111+
content => $_content,
112+
source => $_source,
109113
target => $_target,
110114
owner => $owner,
111115
group => $group,

spec/defines/manage_unit_spec.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,25 @@
127127
}
128128
end
129129

130+
context 'when masking a unit' do
131+
let(:title) { 'tmpfs.mount' }
132+
133+
let(:params) do
134+
{
135+
enable: 'mask',
136+
}
137+
end
138+
139+
it { is_expected.to compile.with_all_deps }
140+
141+
it {
142+
is_expected.to contain_file('/etc/systemd/system/tmpfs.mount').with(
143+
ensure: 'link',
144+
target: '/dev/null'
145+
)
146+
}
147+
end
148+
130149
context 'on a swap' do
131150
let(:title) { 'file.swap' }
132151

0 commit comments

Comments
 (0)