# Copyright 2011 Puppet Labs Inc, unless otherwise noted.
class apt::backports(
$release = $lsbdistcodename,
- $location = $apt::params::backports_locations
+ $location = $apt::params::backports_location
) inherits apt::params {
+ $release_real = downcase($release)
+
apt::source { 'backports.list':
location => $location,
- release => "${release}-backports",
+ release => "${release_real}-backports",
repos => $lsbdistid ? {
'debian' => 'main contrib non-free',
'ubuntu' => 'universe multiverse restricted',
},
key_server => 'pgp.mit.edu',
pin => '200',
- notify => Exec["apt-get update"],
+ notify => Exec["apt_update"],
}
}
-
include apt::params
- $root = "${apt::params::root}"
- $apt_conf_d = "${apt::params::apt_conf_d}"
+ $apt_conf_d = $apt::params::apt_conf_d
file { "${apt_conf_d}/${priority}${name}":
+ ensure => file,
content => $content,
owner => root,
group => root,
- mode => 0644,
+ mode => '0644',
}
}
file { 'sources.list.d':
ensure => directory,
- path => $sources_list_d
+ path => $sources_list_d,
owner => root,
group => root,
purge => $purge_sources_list_d,
'ubuntu': {
case $lsbdistcodename {
'hardy','lucid','maverick','natty','oneiric','precise': {
- $backports_location = http://us.archive.ubuntu.com/ubuntuk
+ $backports_location = 'http://us.archive.ubuntu.com/ubuntu'
}
default: {
- $backports_location = 'http://old-releases.ubuntu.com/ubuntu',
+ $backports_location = 'http://old-releases.ubuntu.com/ubuntu'
}
}
}
file { "${name}.list":
ensure => file,
- path => "${apt::params::sources_list_d}/${name}.list",
+ path => "${sources_list_d}/${name}.list",
owner => root,
group => root,
mode => '0644',
--- /dev/null
+require 'spec_helper'
+describe 'apt::backports', :type => :class do
+
+ describe 'when turning on backports for ubuntu karmic' do
+
+ let :facts do
+ {
+ 'lsbdistcodename' => 'Karmic',
+ 'lsbdistid' => 'Ubuntu'
+ }
+ end
+
+ it { should contain_apt__source('backports.list').with({
+ 'location' => 'http://old-releases.ubuntu.com/ubuntu',
+ 'release' => 'karmic-backports',
+ 'repos' => 'universe multiverse restricted',
+ 'key' => '437D05B5',
+ 'key_server' => 'pgp.mit.edu',
+ 'pin' => '200',
+ 'notify' => 'Exec[apt_update]'
+ })
+ }
+ end
+
+ describe "when turning on backports for debian squeeze" do
+
+ let :facts do
+ {
+ 'lsbdistcodename' => 'Squeeze',
+ 'lsbdistid' => 'Debian',
+ }
+ end
+
+ it { should contain_apt__source('backports.list').with({
+ 'location' => 'http://backports.debian.org/debian-backports',
+ 'release' => 'squeeze-backports',
+ 'repos' => 'main contrib non-free',
+ 'key' => '55BE302B',
+ 'key_server' => 'pgp.mit.edu',
+ 'pin' => '200',
+ 'notify' => 'Exec[apt_update]'
+ })
+ }
+ end
+
+ describe "when turning on backports for debian squeeze but using your own mirror" do
+
+ let :facts do
+ {
+ 'lsbdistcodename' => 'Squeeze',
+ 'lsbdistid' => 'Debian'
+ }
+ end
+
+ let :location do
+ 'http://mirrors.example.com/debian-backports'
+ end
+
+ let :params do
+ { 'location' => location }
+ end
+
+ it { should contain_apt__source('backports.list').with({
+ 'location' => location,
+ 'release' => 'squeeze-backports',
+ 'repos' => 'main contrib non-free',
+ 'key' => '55BE302B',
+ 'key_server' => 'pgp.mit.edu',
+ 'pin' => '200',
+ 'notify' => 'Exec[apt_update]'
+ })
+ }
+ end
+end
--- /dev/null
+require 'spec_helper'
+describe 'apt::conf', :type => :define do
+ let :title do
+ 'norecommends'
+ end
+
+ describe "when creating an apt preference" do
+ let :params do
+ {
+ :priority => '00',
+ :content => "Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;\n"
+ }
+ end
+
+ let :filename do
+ "/etc/apt/apt.conf.d/00norecommends"
+ end
+
+ it { should contain_apt__conf('norecommends').with({
+ 'priority' => '00',
+ 'content' => "Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;\n"
+ })
+ }
+
+ it { should contain_file(filename).with({
+ 'ensure' => 'file',
+ 'content' => "Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;\n",
+ 'owner' => 'root',
+ 'group' => 'root',
+ 'mode' => '0644',
+ })
+ }
+ end
+end