Merge pull request #447 from puppetlabs/daenney/hulk-smash-2
[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   $keyserver      = 'keyserver.ubuntu.com'
15
16   if $::osfamily != 'Debian' {
17     fail('This module only works on Debian or derivatives like Ubuntu')
18   }
19
20   $config_files = {
21     'conf'   => {
22       'path' => $conf_d,
23       'ext'  => '',
24     },
25     'pref'   => {
26       'path' => $preferences_d,
27       'ext'  => '',
28     },
29     'list'   => {
30       'path' => $sources_list_d,
31       'ext'  => '.list',
32     }
33   }
34
35   $update_defaults = {
36     'always'    => false,
37     'frequency' => 'reluctantly',
38     'timeout'   => undef,
39     'tries'     => undef,
40   }
41
42   $proxy_defaults = {
43     'host'  => undef,
44     'port'  => 8080,
45     'https' => false,
46   }
47
48   $purge_defaults = {
49     'sources.list'   => true,
50     'sources.list.d' => true,
51     'preferences'    => true,
52     'preferences.d'  => true,
53   }
54
55   $source_key_defaults = {
56     'server'  => $keyserver,
57     'options' => undef,
58     'content' => undef,
59     'source'  => undef,
60   }
61
62   $file_defaults = {
63     'owner' => 'root',
64     'group' => 'root',
65     'mode'  => '0644',
66   }
67
68   case $::lsbdistid {
69     'ubuntu', 'debian': {
70       $distid = $::lsbdistid
71       $distcodename = $::lsbdistcodename
72     }
73     'linuxmint': {
74       if $::lsbdistcodename == 'debian' {
75         $distid = 'debian'
76         $distcodename = 'wheezy'
77       } else {
78         $distid = 'ubuntu'
79         $distcodename = $::lsbdistcodename ? {
80           'qiana'  => 'trusty',
81           'petra'  => 'saucy',
82           'olivia' => 'raring',
83           'nadia'  => 'quantal',
84           'maya'   => 'precise',
85         }
86       }
87     }
88     '': {
89       fail('Unable to determine lsbdistid, is lsb-release installed?')
90     }
91     default: {
92       fail("Unsupported lsbdistid (${::lsbdistid})")
93     }
94   }
95   case $distid {
96     'ubuntu': {
97       case $distcodename {
98         'lucid': {
99           $ppa_options        = undef
100           $ppa_package        = 'python-software-properties'
101         }
102         'precise': {
103           $ppa_options        = '-y'
104           $ppa_package        = 'python-software-properties'
105         }
106         'trusty', 'utopic', 'vivid': {
107           $ppa_options        = '-y'
108           $ppa_package        = 'software-properties-common'
109         }
110         default: {
111           $ppa_options        = '-y'
112           $ppa_package        = 'software-properties-common'
113         }
114       }
115     }
116   }
117 }