(MODULES-7153) - Unmanage gitlab-ci.yml
[puppet-modules/puppetlabs-apt.git] / manifests / backports.pp
1 # Defining backports for the apt class
2 class apt::backports (
3   Optional[String] $location                    = undef,
4   Optional[String] $release                     = undef,
5   Optional[String] $repos                       = undef,
6   Optional[Variant[String, Hash]] $key          = undef,
7   Optional[Variant[Integer, String, Hash]] $pin = 200,
8 ){
9   if $location {
10     $_location = $location
11   }
12   if $release {
13     $_release = $release
14   }
15   if $repos {
16     $_repos = $repos
17   }
18   if $key {
19     $_key = $key
20   }
21   if ($facts['lsbdistid'] == 'Debian' or $facts['lsbdistid'] == 'Ubuntu') {
22     unless $location {
23       $_location = $::apt::backports['location']
24     }
25     unless $release {
26       $_release = "${facts['lsbdistcodename']}-backports"
27     }
28     unless $repos {
29       $_repos = $::apt::backports['repos']
30     }
31     unless $key {
32       $_key =  $::apt::backports['key']
33     }
34   } else {
35     unless $location and $release and $repos and $key {
36       fail('If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key')
37     }
38   }
39
40   if $pin =~ Hash {
41     $_pin = $pin
42   } elsif $pin =~ Numeric or $pin =~ String {
43     # apt::source defaults to pinning to origin, but we should pin to release
44     # for backports
45     $_pin = {
46       'priority' => $pin,
47       'release'  => $_release,
48     }
49   } else {
50     fail('pin must be either a string, number or hash')
51   }
52
53   apt::source { 'backports':
54     location => $_location,
55     release  => $_release,
56     repos    => $_repos,
57     key      => $_key,
58     pin      => $_pin,
59   }
60 }