Revert "Fix use of $::apt::params::backports and $::apt::params::xfacts."
[puppet-modules/puppetlabs-apt.git] / manifests / backports.pp
1 class apt::backports (
2   $location = undef,
3   $release  = undef,
4   $repos    = undef,
5   $key      = undef,
6   $pin      = 200,
7 ){
8   if $location {
9     validate_string($location)
10     $_location = $location
11   }
12   if $release {
13     validate_string($release)
14     $_release = $release
15   }
16   if $repos {
17     validate_string($repos)
18     $_repos = $repos
19   }
20   if $key {
21     unless is_hash($key) {
22       validate_string($key)
23     }
24     $_key = $key
25   }
26   unless is_hash($pin) {
27     unless (is_numeric($pin) or is_string($pin)) {
28       fail('pin must be either a string, number or hash')
29     }
30   }
31
32   if ($::apt::xfacts['lsbdistid'] == 'debian' or $::apt::xfacts['lsbdistid'] == 'ubuntu') {
33     unless $location {
34       $_location = $::apt::backports['location']
35     }
36     unless $release {
37       $_release = "${::apt::xfacts['lsbdistcodename']}-backports"
38     }
39     unless $repos {
40       $_repos = $::apt::backports['repos']
41     }
42     unless $key {
43       $_key =  $::apt::backports['key']
44     }
45   } else {
46     unless $location and $release and $repos and $key {
47       fail('If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key')
48     }
49   }
50
51   apt::source { 'backports':
52     location => $_location,
53     release  => $_release,
54     repos    => $_repos,
55     key      => $_key,
56     pin      => $pin,
57   }
58
59 }