diff --git a/manifests/source.pp b/manifests/source.pp index 7a44221497..7422fecbd9 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -254,6 +254,7 @@ 'components' => $_components, } ) + $_content = "${header}${source_content}" if $pin { if $pin =~ Hash { @@ -346,10 +347,10 @@ } ) ) + $_content = "${header}${source_content}" } 'absent': { - $header = undef - $source_content = undef + $_content = undef } default: { fail('Unexpected value for $ensure parameter.') @@ -362,7 +363,7 @@ } apt::setting { "${_file_suffix}-${name}": ensure => $ensure, - content => "${header}${source_content}", + content => $_content, notify_update => $notify_update, } } diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index db28d23f2d..be25caa564 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -516,5 +516,36 @@ it { is_expected.to contain_apt__setting("sources-#{title}").with_notify_update(true) } end + + context 'absent deb822 source' do + let :params do + super().merge( + { + ensure: 'absent', + }, + ) + end + + it { is_expected.to contain_apt__setting("sources-#{title}").with_ensure('absent') } + end + + context 'absent complex deb822 source' do + let :params do + super().merge( + { + ensure: 'absent', + types: ['deb', 'deb-src'], + location: ['http://fr.debian.org/debian', 'http://de.debian.org/debian'], + release: ['stable', 'stable-updates', 'stable-backports'], + repos: ['main', 'contrib', 'non-free'], + architecture: ['amd64', 'i386'], + allow_unsigned: true, + notify_update: false + }, + ) + end + + it { is_expected.to contain_apt__setting("sources-#{title}").with_ensure('absent') } + end end end