Merge pull request #20 from blkperl/ticket_12522_purge_option

(#12522) Adding purge option to apt class

Reviewed by Ryan Coleman
This commit is contained in:
Ryan Coleman 2012-02-23 14:31:45 -08:00
commit c09f476b9d
3 changed files with 63 additions and 17 deletions

11
Modulefile Normal file
View file

@ -0,0 +1,11 @@
name 'puppet-apt'
version '0.0.1'
source 'https://github.com/puppetlabs/puppet-apt'
author 'Evolving Web / Puppet Labs'
license 'Apache License 2.0'
summary 'Apt Module for Puppet'
description 'APT Module for Puppet'
project_page 'https://github.com/puppetlabs/puppet-apt'
## Add dependencies, if any:
dependency 'puppetlabs/stdlib', '>= 2.2.1'

View file

@ -15,14 +15,17 @@
# Sample Usage:
# class { 'apt': }
class apt(
$disable_keys = false,
$always_apt_update = false,
$disable_keys = false,
$proxy_host = false,
$proxy_port = '8080'
$proxy_port = '8080',
$purge = false
) {
include apt::params
validate_bool($purge)
$refresh_only_apt_update = $always_apt_update? {
true => false,
false => true
@ -36,6 +39,10 @@ class apt(
owner => root,
group => root,
mode => 644,
content => $purge ? {
false => undef,
true => "# Repos managed by puppet.\n",
},
}
file { "sources.list.d":
@ -43,6 +50,8 @@ class apt(
ensure => directory,
owner => root,
group => root,
purge => $purge,
recurse => $purge,
}
exec { "apt_update":

View file

@ -3,7 +3,8 @@ describe 'apt', :type => :class do
let :default_params do
{
:disable_keys => false,
:always_apt_update => false
:always_apt_update => false,
:purge => false
}
end
@ -12,7 +13,8 @@ describe 'apt', :type => :class do
:disable_keys => true,
:always_apt_update => true,
:proxy_host => true,
:proxy_port => '3128'
:proxy_port => '3128',
:purge => true
}
].each do |param_set|
describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do
@ -37,22 +39,46 @@ describe 'apt', :type => :class do
it { should contain_package("python-software-properties") }
it {
if param_hash[:purge]
should contain_file("sources.list").with({
'path' => "/etc/apt/sources.list",
'ensure' => "present",
'owner' => "root",
'group' => "root",
'mode' => 644
})
'path' => "/etc/apt/sources.list",
'ensure' => "present",
'owner' => "root",
'group' => "root",
'mode' => 644,
"content" => "# Repos managed by puppet.\n"
})
else
should contain_file("sources.list").with({
'path' => "/etc/apt/sources.list",
'ensure' => "present",
'owner' => "root",
'group' => "root",
'mode' => 644,
'content' => nil
})
end
}
it {
should create_file("sources.list.d").with({
"path" => "/etc/apt/sources.list.d",
"ensure" => "directory",
"owner" => "root",
"group" => "root"
})
if param_hash[:purge]
should create_file("sources.list.d").with({
'path' => "/etc/apt/sources.list.d",
'ensure' => "directory",
'owner' => "root",
'group' => "root",
'purge' => true,
'recurse' => true
})
else
should create_file("sources.list.d").with({
'path' => "/etc/apt/sources.list.d",
'ensure' => "directory",
'owner' => "root",
'group' => "root",
'purge' => false,
'recurse' => false
})
end
}
it {