Merge pull request #25 from rcoleman/ticket_12522_purge_option_take_2

(#12522) Split purge option to spare sources.list
This commit is contained in:
Matthaus Litteken 2012-02-24 10:29:09 -08:00
commit e68e663f28
2 changed files with 18 additions and 10 deletions

View file

@ -3,11 +3,16 @@
# This module manages the initial configuration of apt.
#
# Parameters:
# Both of the parameters listed here are not required in general and were
# The parameters listed here are not required in general and were
# added for use cases related to development environments.
# disable_keys - disables the requirement for all packages to be signed
# always_apt_update - rather apt should be updated on every run (intended
# for development environments where package updates are frequent
# purge_sources_list - Accepts true or false. Defaults to false If set to
# true, Puppet will purge all unmanaged entries from sources.list"
# purge_sources_list_d - Accepts true or false. Defaults to false. If set
# to false, Puppet will purge all unmanaged entries from sources.list.d
#
# Actions:
#
# Requires:
@ -19,12 +24,13 @@ class apt(
$disable_keys = undef,
$proxy_host = false,
$proxy_port = '8080',
$purge = false
$purge_sources_list = false,
$purge_sources_list_d = false
) {
include apt::params
validate_bool($purge)
validate_bool($purge_sources_list, $purge_sources_list_d)
$refresh_only_apt_update = $always_apt_update? {
true => false,
@ -39,7 +45,7 @@ class apt(
owner => root,
group => root,
mode => 644,
content => $purge ? {
content => $purge_sources_list ? {
false => undef,
true => "# Repos managed by puppet.\n",
},
@ -50,8 +56,8 @@ class apt(
ensure => directory,
owner => root,
group => root,
purge => $purge,
recurse => $purge,
purge => $purge_sources_list_d,
recurse => $purge_sources_list_d,
}
exec { "apt_update":

View file

@ -4,7 +4,8 @@ describe 'apt', :type => :class do
{
:disable_keys => :undef,
:always_apt_update => false,
:purge => false
:purge_sources_list => false,
:purge_sources_list_d => false,
}
end
@ -14,7 +15,8 @@ describe 'apt', :type => :class do
:always_apt_update => true,
:proxy_host => true,
:proxy_port => '3128',
:purge => true
:purge_sources_list => true,
:purge_sources_list_d => true,
},
{
:disable_keys => false
@ -42,7 +44,7 @@ describe 'apt', :type => :class do
it { should contain_package("python-software-properties") }
it {
if param_hash[:purge]
if param_hash[:purge_sources_list]
should contain_file("sources.list").with({
'path' => "/etc/apt/sources.list",
'ensure' => "present",
@ -63,7 +65,7 @@ describe 'apt', :type => :class do
end
}
it {
if param_hash[:purge]
if param_hash[:purge_sources_list_d]
should create_file("sources.list.d").with({
'path' => "/etc/apt/sources.list.d",
'ensure' => "directory",