8edd2e7840583141b944e2e288c415f20b0f8ff4
[puppet-modules/puppetlabs-apt.git] / manifests / params.pp
1 class apt::params {
2
3   if defined('$caller_module_name') and $caller_module_name and $caller_module_name != $module_name {
4     fail('apt::params is a private class and cannot be accessed directly')
5   }
6
7   if $::osfamily != 'Debian' {
8     fail('This module only works on Debian or derivatives like Ubuntu')
9   }
10
11   $xfacts = {
12     'lsbdistcodename' => defined('$lsbdistcodename') ? {
13       true    => $::lsbdistcodename,
14       default => undef
15     },
16   }
17
18   $root           = '/etc/apt'
19   $provider       = '/usr/bin/apt-get'
20   $sources_list   = "${root}/sources.list"
21   $sources_list_d = "${root}/sources.list.d"
22   $conf_d         = "${root}/apt.conf.d"
23   $preferences    = "${root}/preferences"
24   $preferences_d  = "${root}/preferences.d"
25   $keyserver      = 'keyserver.ubuntu.com'
26
27   $config_files = {
28     'conf'   => {
29       'path' => $conf_d,
30       'ext'  => '',
31     },
32     'pref'   => {
33       'path' => $preferences_d,
34       'ext'  => '',
35     },
36     'list'   => {
37       'path' => $sources_list_d,
38       'ext'  => '.list',
39     }
40   }
41
42   $update_defaults = {
43     'always'    => false,
44     'frequency' => 'reluctantly',
45     'timeout'   => undef,
46     'tries'     => undef,
47   }
48
49   $proxy_defaults = {
50     'host'  => undef,
51     'port'  => 8080,
52     'https' => false,
53   }
54
55   $purge_defaults = {
56     'sources.list'   => true,
57     'sources.list.d' => true,
58     'preferences'    => true,
59     'preferences.d'  => true,
60   }
61
62   $source_key_defaults = {
63     'server'  => $keyserver,
64     'options' => undef,
65     'content' => undef,
66     'source'  => undef,
67   }
68
69   $file_defaults = {
70     'owner' => 'root',
71     'group' => 'root',
72     'mode'  => '0644',
73   }
74
75   case $::lsbdistid {
76     'ubuntu', 'debian': {
77       $distid = $::lsbdistid
78       $distcodename = $xfacts['lsbdistcodename']
79     }
80     'linuxmint': {
81       if $::lsbdistcodename == 'debian' {
82         $distid = 'debian'
83         $distcodename = 'wheezy'
84       } else {
85         $distid = 'ubuntu'
86         $distcodename = $::lsbdistcodename ? {
87           'qiana'  => 'trusty',
88           'petra'  => 'saucy',
89           'olivia' => 'raring',
90           'nadia'  => 'quantal',
91           'maya'   => 'precise',
92         }
93       }
94     }
95     '': {
96       fail('Unable to determine lsbdistid, is lsb-release installed?')
97     }
98     default: {
99       fail("Unsupported lsbdistid (${::lsbdistid})")
100     }
101   }
102   case $distid {
103     'ubuntu': {
104       case $distcodename {
105         'lucid': {
106           $ppa_options        = undef
107           $ppa_package        = 'python-software-properties'
108         }
109         'precise': {
110           $ppa_options        = '-y'
111           $ppa_package        = 'python-software-properties'
112         }
113         'trusty', 'utopic', 'vivid': {
114           $ppa_options        = '-y'
115           $ppa_package        = 'software-properties-common'
116         }
117         default: {
118           $ppa_options        = '-y'
119           $ppa_package        = 'software-properties-common'
120         }
121       }
122     }
123     '', default: {
124       $ppa_options = undef
125       $ppa_package = undef
126     }
127   }
128 }