Merge pull request #461 from mhaskel/boo_inheritance
[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     'always'    => false,
61     'frequency' => 'reluctantly',
62     'timeout'   => undef,
63     'tries'     => undef,
64   }
65
66   $proxy_defaults = {
67     'host'  => undef,
68     'port'  => 8080,
69     'https' => false,
70   }
71
72   $purge_defaults = {
73     'sources.list'   => true,
74     'sources.list.d' => true,
75     'preferences'    => true,
76     'preferences.d'  => true,
77   }
78
79   $source_key_defaults = {
80     'server'  => $keyserver,
81     'options' => undef,
82     'content' => undef,
83     'source'  => undef,
84   }
85
86   $include_defaults = {
87     'deb' => true,
88     'src' => false,
89   }
90
91   case $xfacts['lsbdistid'] {
92     'ubuntu', 'debian': {
93       $distid = $xfacts['lsbdistid']
94       $distcodename = $xfacts['lsbdistcodename']
95     }
96     'linuxmint': {
97       if $xfacts['lsbdistcodename'] == 'debian' {
98         $distid = 'debian'
99         $distcodename = 'wheezy'
100       } else {
101         $distid = 'ubuntu'
102         $distcodename = $xfacts['lsbdistcodename'] ? {
103           'qiana'  => 'trusty',
104           'petra'  => 'saucy',
105           'olivia' => 'raring',
106           'nadia'  => 'quantal',
107           'maya'   => 'precise',
108         }
109       }
110     }
111     undef: {
112       fail('Unable to determine lsbdistid, is lsb-release installed?')
113     }
114     default: {
115       fail("Unsupported lsbdistid (${::lsbdistid})")
116     }
117   }
118   case $distid {
119     'ubuntu': {
120       case $distcodename {
121         'lucid': {
122           $ppa_options        = undef
123           $ppa_package        = 'python-software-properties'
124         }
125         'precise': {
126           $ppa_options        = '-y'
127           $ppa_package        = 'python-software-properties'
128         }
129         'trusty', 'utopic', 'vivid': {
130           $ppa_options        = '-y'
131           $ppa_package        = 'software-properties-common'
132         }
133         default: {
134           $ppa_options        = '-y'
135           $ppa_package        = 'software-properties-common'
136         }
137       }
138     }
139     '', default: {
140       $ppa_options = undef
141       $ppa_package = undef
142     }
143   }
144 }