Cleanup for apt::source
* Update `release` to default to `$::lsbdistcodename` * Default `include_src` to false * Validate more things! * Stop redefining variables from `apt::params`
This commit is contained in:
parent
7e7e3e2f50
commit
0a178c3382
4 changed files with 10 additions and 16 deletions
|
@ -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":
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 -%>
|
||||
|
|
Loading…
Reference in a new issue