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
|
# source.pp
|
||||||
# add an apt source
|
# add an apt source
|
||||||
|
|
||||||
define apt::source(
|
define apt::source(
|
||||||
$comment = $name,
|
$comment = $name,
|
||||||
$ensure = present,
|
$ensure = present,
|
||||||
$location = '',
|
$location = '',
|
||||||
$release = 'UNDEF',
|
$release = $::lsbdistcodename,
|
||||||
$repos = 'main',
|
$repos = 'main',
|
||||||
$include_src = true,
|
$include_src = false,
|
||||||
$include_deb = true,
|
$include_deb = true,
|
||||||
$key = undef,
|
$key = undef,
|
||||||
$key_server = 'keyserver.ubuntu.com',
|
$key_server = 'keyserver.ubuntu.com',
|
||||||
|
@ -17,17 +16,11 @@ define apt::source(
|
||||||
$architecture = undef,
|
$architecture = undef,
|
||||||
$trusted_source = false,
|
$trusted_source = false,
|
||||||
) {
|
) {
|
||||||
validate_string($architecture)
|
validate_string($architecture, $comment, $location, $release, $repos, $key_server)
|
||||||
validate_bool($trusted_source)
|
validate_bool($trusted_source, $include_src, $include_deb)
|
||||||
|
|
||||||
if $release == 'UNDEF' {
|
if ! $release {
|
||||||
if $::lsbdistcodename == undef {
|
fail('lsbdistcodename fact not available: release parameter required')
|
||||||
fail('lsbdistcodename fact not available: release parameter required')
|
|
||||||
} else {
|
|
||||||
$release_real = $::lsbdistcodename
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$release_real = $release
|
|
||||||
}
|
}
|
||||||
|
|
||||||
file { "${name}.list":
|
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 http:\/\/apt.puppetlabs.com precise main$/) }
|
||||||
it { should contain_file('puppetlabs.list').with_content(/^deb-src http:\/\/apt.puppetlabs.com precise main$/) }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'failing tests' do
|
describe 'failing tests' do
|
||||||
|
|
|
@ -23,6 +23,7 @@ describe 'apt::source', :type => :define do
|
||||||
let :params do
|
let :params do
|
||||||
{
|
{
|
||||||
'include_deb' => false,
|
'include_deb' => false,
|
||||||
|
'include_src' => true,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -123,6 +124,7 @@ describe 'apt::source', :type => :define do
|
||||||
let :params do
|
let :params do
|
||||||
{
|
{
|
||||||
'include_deb' => false,
|
'include_deb' => false,
|
||||||
|
'include_src' => true,
|
||||||
'architecture' => 'x86_64',
|
'architecture' => 'x86_64',
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
<%- if @include_deb then -%>
|
<%- if @include_deb then -%>
|
||||||
deb <%- if @architecture or @trusted_source -%>
|
deb <%- if @architecture or @trusted_source -%>
|
||||||
[<%- if @architecture %>arch=<%= @architecture %> <% end %><% if @trusted_source %>trusted=yes<% end -%>
|
[<%- if @architecture %>arch=<%= @architecture %> <% end %><% if @trusted_source %>trusted=yes<% end -%>
|
||||||
] <%- end %><%= @location %> <%= @release_real %> <%= @repos %>
|
] <%- end %><%= @location %> <%= @release %> <%= @repos %>
|
||||||
<%- end -%>
|
<%- end -%>
|
||||||
<%- if @include_src then -%>
|
<%- if @include_src then -%>
|
||||||
deb-src <%- if @architecture or @trusted_source -%>
|
deb-src <%- if @architecture or @trusted_source -%>
|
||||||
[<%- if @architecture %>arch=<%= @architecture %> <% end %><% if @trusted_source %>trusted=yes<% end -%>
|
[<%- if @architecture %>arch=<%= @architecture %> <% end %><% if @trusted_source %>trusted=yes<% end -%>
|
||||||
] <%- end %><%= @location %> <%= @release_real %> <%= @repos %>
|
] <%- end %><%= @location %> <%= @release %> <%= @repos %>
|
||||||
<%- end -%>
|
<%- end -%>
|
||||||
|
|
Loading…
Reference in a new issue