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