diff --git a/manifests/unit_file.pp b/manifests/unit_file.pp index 237e27a9..cf7aad6d 100644 --- a/manifests/unit_file.pp +++ b/manifests/unit_file.pp @@ -92,8 +92,12 @@ if $enable == 'mask' { $_target = '/dev/null' + $_content = undef + $_source = undef } else { $_target = $target + $_content = $content + $_source = $source } if $_target { @@ -104,8 +108,8 @@ file { "${path}/${name}": ensure => $_ensure, - content => $content, - source => $source, + content => $_content, + source => $_source, target => $_target, owner => $owner, group => $group, diff --git a/spec/defines/manage_unit_spec.rb b/spec/defines/manage_unit_spec.rb index 003e0acc..8541df11 100644 --- a/spec/defines/manage_unit_spec.rb +++ b/spec/defines/manage_unit_spec.rb @@ -127,6 +127,25 @@ } end + context 'when masking a unit' do + let(:title) { 'tmpfs.mount' } + + let(:params) do + { + enable: 'mask', + } + end + + it { is_expected.to compile.with_all_deps } + + it { + is_expected.to contain_file('/etc/systemd/system/tmpfs.mount').with( + ensure: 'link', + target: '/dev/null' + ) + } + end + context 'on a swap' do let(:title) { 'file.swap' }