diff --git a/manifests/source.pp b/manifests/source.pp index 78b861f..0ca5212 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -1,13 +1,12 @@ # source.pp # add an apt source - define apt::source( $comment = $name, $ensure = present, $location = '', - $release = 'UNDEF', + $release = $::lsbdistcodename, $repos = 'main', - $include_src = true, + $include_src = false, $include_deb = true, $key = undef, $key_server = 'keyserver.ubuntu.com', @@ -17,17 +16,11 @@ define apt::source( $architecture = undef, $trusted_source = false, ) { - validate_string($architecture) - validate_bool($trusted_source) + validate_string($architecture, $comment, $location, $release, $repos, $key_server) + validate_bool($trusted_source, $include_src, $include_deb) - if $release == 'UNDEF' { - if $::lsbdistcodename == undef { - fail('lsbdistcodename fact not available: release parameter required') - } else { - $release_real = $::lsbdistcodename - } - } else { - $release_real = $release + if ! $release { + fail('lsbdistcodename fact not available: release parameter required') } file { "${name}.list": diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index b92f7dd..d4be964 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -135,7 +135,6 @@ describe 'apt', :type => :class do } it { should contain_file('puppetlabs.list').with_content(/^deb http:\/\/apt.puppetlabs.com precise main$/) } - it { should contain_file('puppetlabs.list').with_content(/^deb-src http:\/\/apt.puppetlabs.com precise main$/) } end describe 'failing tests' do diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index 7a1cac3..ff236bd 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -23,6 +23,7 @@ describe 'apt::source', :type => :define do let :params do { 'include_deb' => false, + 'include_src' => true, } end @@ -123,6 +124,7 @@ describe 'apt::source', :type => :define do let :params do { 'include_deb' => false, + 'include_src' => true, 'architecture' => 'x86_64', } end diff --git a/templates/source.list.erb b/templates/source.list.erb index b50be8d..fb0a386 100644 --- a/templates/source.list.erb +++ b/templates/source.list.erb @@ -2,10 +2,10 @@ <%- if @include_deb then -%> deb <%- if @architecture or @trusted_source -%> [<%- if @architecture %>arch=<%= @architecture %> <% end %><% if @trusted_source %>trusted=yes<% end -%> -] <%- end %><%= @location %> <%= @release_real %> <%= @repos %> +] <%- end %><%= @location %> <%= @release %> <%= @repos %> <%- end -%> <%- if @include_src then -%> deb-src <%- if @architecture or @trusted_source -%> [<%- if @architecture %>arch=<%= @architecture %> <% end %><% if @trusted_source %>trusted=yes<% end -%> -] <%- end %><%= @location %> <%= @release_real %> <%= @repos %> +] <%- end %><%= @location %> <%= @release %> <%= @repos %> <%- end -%>