Merge pull request #484 from mhaskel/merge_master_to_next
[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'   => true,
73     'sources.list.d' => true,
74     'preferences'    => true,
75     'preferences.d'  => true,
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     'ubuntu', 'debian': {
92       $distid = $xfacts['lsbdistid']
93       $distcodename = $xfacts['lsbdistcodename']
94     }
95     'linuxmint': {
96       if $xfacts['lsbdistcodename'] == 'debian' {
97         $distid = 'debian'
98         $distcodename = 'wheezy'
99       } else {
100         $distid = 'ubuntu'
101         $distcodename = $xfacts['lsbdistcodename'] ? {
102           'qiana'  => 'trusty',
103           'petra'  => 'saucy',
104           'olivia' => 'raring',
105           'nadia'  => 'quantal',
106           'maya'   => 'precise',
107         }
108       }
109     }
110     'Cumulus Networks': {
111       $distid = 'debian'
112       $distcodename = $::lsbdistcodename
113     }
114     undef: {
115       fail('Unable to determine lsbdistid, is lsb-release installed?')
116     }
117     default: {
118       fail("Unsupported lsbdistid (${::lsbdistid})")
119     }
120   }
121   case $distid {
122     'ubuntu': {
123       case $distcodename {
124         'lucid': {
125           $ppa_options        = undef
126           $ppa_package        = 'python-software-properties'
127         }
128         'precise': {
129           $ppa_options        = '-y'
130           $ppa_package        = 'python-software-properties'
131         }
132         'trusty', 'utopic', 'vivid': {
133           $ppa_options        = '-y'
134           $ppa_package        = 'software-properties-common'
135         }
136         default: {
137           $ppa_options        = '-y'
138           $ppa_package        = 'python-software-properties'
139         }
140       }
141     }
142     '', default: {
143       $ppa_options = undef
144       $ppa_package = undef
145     }
146   }
147 }