diff --git a/manifests/source.pp b/manifests/source.pp index 2c26227..a859174 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -4,7 +4,7 @@ define apt::source( $ensure = present, $location = '', - $release = $::lsbdistcodename, + $release = 'UNDEF', $repos = 'main', $include_src = true, $required_packages = false, @@ -21,8 +21,14 @@ define apt::source( $sources_list_d = $apt::params::sources_list_d $provider = $apt::params::provider - if $release == undef { - fail('lsbdistcodename fact not available: release parameter required') + if $release == 'UNDEF' { + if $::lsbdistcodename == undef { + fail('lsbdistcodename fact not available: release parameter required') + } else { + $release_real = $::lsbdistcodename + } + } else { + $release_real = $release } file { "${name}.list": diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index 583c619..0f37f63 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -42,6 +42,12 @@ describe 'apt::source', :type => :define do :location => 'http://example.com', :release => 'precise', :repos => 'security', + }, + { + :release => '', + }, + { + :release => 'custom', } ].each do |param_set| describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do diff --git a/templates/source.list.erb b/templates/source.list.erb index 3452691..faa7e28 100644 --- a/templates/source.list.erb +++ b/templates/source.list.erb @@ -1,5 +1,5 @@ # <%= name %> -deb <%= location %> <%= release %> <%= repos %> +deb <%= location %> <%= release_real %> <%= repos %> <%- if include_src then -%> -deb-src <%= location %> <%= release %> <%= repos %> +deb-src <%= location %> <%= release_real %> <%= repos %> <%- end -%>