Merge pull request #502 from mhaskel/merge_2.0.x_to_master
[puppet-modules/puppetlabs-apt.git] / manifests / params.pp
1 class apt::params {
2
3   if $::osfamily != 'Debian' {
4     fail('This module only works on Debian or derivatives like Ubuntu')
5   }
6
7   # Strict variables facts lookup compatibility
8   $xfacts = {
9     'lsbdistcodename' => defined('$lsbdistcodename') ? {
10       true    => $::lsbdistcodename,
11       default => undef,
12     },
13     'lsbdistrelease' => defined('$lsbdistrelease') ? {
14       true    => $::lsbdistrelease,
15       default => undef,
16     },
17     'lsbmajdistrelease' => defined('$lsbmajdistrelease') ? {
18       true    => $::lsbmajdistrelease,
19       default => undef,
20     },
21     'lsbdistdescription' => defined('$lsbdistdescription') ? {
22       true    => $::lsbdistdescription,
23       default => undef,
24     },
25     'lsbminordistrelease' => defined('$lsbminordistrelease') ? {
26       true    => $::lsbminordistrelease,
27       default => undef,
28     },
29     'lsbdistid' => defined('$lsbdistid') ? {
30       true    => $::lsbdistid,
31       default => undef,
32     },
33   }
34
35   $root           = '/etc/apt'
36   $provider       = '/usr/bin/apt-get'
37   $sources_list   = "${root}/sources.list"
38   $sources_list_d = "${root}/sources.list.d"
39   $conf_d         = "${root}/apt.conf.d"
40   $preferences    = "${root}/preferences"
41   $preferences_d  = "${root}/preferences.d"
42   $keyserver      = 'keyserver.ubuntu.com'
43
44   $config_files = {
45     'conf'   => {
46       'path' => $conf_d,
47       'ext'  => '',
48     },
49     'pref'   => {
50       'path' => $preferences_d,
51       'ext'  => '',
52     },
53     'list'   => {
54       'path' => $sources_list_d,
55       'ext'  => '.list',
56     }
57   }
58
59   $update_defaults = {
60     'frequency' => 'reluctantly',
61     'timeout'   => undef,
62     'tries'     => undef,
63   }
64
65   $proxy_defaults = {
66     'host'  => undef,
67     'port'  => 8080,
68     'https' => false,
69   }
70
71   $purge_defaults = {
72     'sources.list'   => false,
73     'sources.list.d' => false,
74     'preferences'    => false,
75     'preferences.d'  => false,
76   }
77
78   $source_key_defaults = {
79     'server'  => $keyserver,
80     'options' => undef,
81     'content' => undef,
82     'source'  => undef,
83   }
84
85   $include_defaults = {
86     'deb' => true,
87     'src' => false,
88   }
89
90   case $xfacts['lsbdistid'] {
91     'debian': {
92       case $xfacts['lsbdistcodename'] {
93         'squeeze': {
94           $backports = {
95             'location' => 'http://backports.debian.org/debian-backports',
96             'key'      => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553',
97             'repos'    => 'main contrib non-free',
98           }
99         }
100         default: {
101           $backports = {
102             'location' => 'http://ftp.debian.org/debian/',
103             'key'      => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553',
104             'repos'    => 'main contrib non-free',
105           }
106         }
107       }
108     }
109     'ubuntu': {
110       $backports = {
111         'location' => 'http://archive.ubuntu.com/ubuntu',
112         'key'      => '630239CC130E1A7FD81A27B140976EAF437D05B5',
113         'repos'    => 'main universe multiverse restricted',
114       }
115
116       case $xfacts['lsbdistcodename'] {
117         'lucid': {
118           $ppa_options        = undef
119           $ppa_package        = 'python-software-properties'
120         }
121         'precise': {
122           $ppa_options        = '-y'
123           $ppa_package        = 'python-software-properties'
124         }
125         'trusty', 'utopic', 'vivid': {
126           $ppa_options        = '-y'
127           $ppa_package        = 'software-properties-common'
128         }
129         default: {
130           $ppa_options        = '-y'
131           $ppa_package        = 'python-software-properties'
132         }
133       }
134     }
135     undef: {
136       fail('Unable to determine lsbdistid, is lsb-release installed?')
137     }
138     default: {
139       $ppa_options = undef
140       $ppa_package = undef
141       $backports   = undef
142     }
143   }
144 }