388
|
1 # == Class: common
|
|
2 #
|
|
3 # This class is applied to *ALL* nodes
|
|
4 #
|
|
5 # === Copyright
|
|
6 #
|
|
7 # Copyright 2013 GH Solutions, LLC
|
|
8 #
|
|
9 class common (
|
|
10 $users = undef,
|
|
11 $groups = undef,
|
|
12 $manage_root_password = false,
|
|
13 $root_password = '$1$cI5K51$dexSpdv6346YReZcK2H1k.', # puppet
|
|
14 $create_opt_lsb_provider_name_dir = false,
|
|
15 $lsb_provider_name = 'UNSET',
|
|
16 $enable_dnsclient = false,
|
|
17 $enable_hosts = false,
|
|
18 $enable_inittab = false,
|
|
19 $enable_mailaliases = false,
|
|
20 $enable_motd = false,
|
|
21 $enable_network = false,
|
|
22 $enable_nsswitch = false,
|
|
23 $enable_ntp = false,
|
|
24 $enable_pam = false,
|
|
25 $enable_puppet_agent = false,
|
|
26 $enable_rsyslog = false,
|
|
27 $enable_selinux = false,
|
|
28 $enable_ssh = false,
|
|
29 $enable_utils = false,
|
|
30 $enable_vim = false,
|
|
31 $enable_wget = false,
|
|
32 # include classes based on osfamily fact
|
|
33 $enable_debian = false,
|
|
34 $enable_redhat = false,
|
|
35 $enable_solaris = false,
|
|
36 $enable_suse = false,
|
|
37 ) {
|
|
38
|
|
39 # validate type and convert string to boolean if necessary
|
|
40 if is_string($enable_dnsclient) {
|
|
41 $dnsclient_enabled = str2bool($enable_dnsclient)
|
|
42 } else {
|
|
43 $dnsclient_enabled = $enable_dnsclient
|
|
44 }
|
|
45 if $dnsclient_enabled == true {
|
|
46 include ::dnsclient
|
|
47 }
|
|
48
|
|
49 # validate type and convert string to boolean if necessary
|
|
50 if is_string($enable_hosts) {
|
|
51 $hosts_enabled = str2bool($enable_hosts)
|
|
52 } else {
|
|
53 $hosts_enabled = $enable_hosts
|
|
54 }
|
|
55 if $hosts_enabled == true {
|
|
56 include ::hosts
|
|
57 }
|
|
58
|
|
59 # validate type and convert string to boolean if necessary
|
|
60 if is_string($enable_inittab) {
|
|
61 $inittab_enabled = str2bool($enable_inittab)
|
|
62 } else {
|
|
63 $inittab_enabled = $enable_inittab
|
|
64 }
|
|
65 if $inittab_enabled == true {
|
|
66 include ::inittab
|
|
67 }
|
|
68
|
|
69 # validate type and convert string to boolean if necessary
|
|
70 if is_string($enable_mailaliases) {
|
|
71 $mailaliases_enabled = str2bool($enable_mailaliases)
|
|
72 } else {
|
|
73 $mailaliases_enabled = $enable_mailaliases
|
|
74 }
|
|
75 if $mailaliases_enabled == true {
|
|
76 include ::mailaliases
|
|
77 }
|
|
78
|
|
79 # validate type and convert string to boolean if necessary
|
|
80 if is_string($enable_mailaliases) {
|
|
81 $motd_enabled = str2bool($enable_motd)
|
|
82 } else {
|
|
83 $motd_enabled = $enable_motd
|
|
84 }
|
|
85 if $motd_enabled == true {
|
|
86 include ::motd
|
|
87 }
|
|
88
|
|
89 # validate type and convert string to boolean if necessary
|
|
90 if is_string($enable_network) {
|
|
91 $network_enabled = str2bool($enable_network)
|
|
92 } else {
|
|
93 $network_enabled = $enable_network
|
|
94 }
|
|
95 if $network_enabled == true {
|
|
96 include ::network
|
|
97 }
|
|
98
|
|
99 # validate type and convert string to boolean if necessary
|
|
100 if is_string($enable_nsswitch) {
|
|
101 $nsswitch_enabled = str2bool($enable_nsswitch)
|
|
102 } else {
|
|
103 $nsswitch_enabled = $enable_nsswitch
|
|
104 }
|
|
105 if $nsswitch_enabled == true {
|
|
106 include ::nsswitch
|
|
107 }
|
|
108
|
|
109 # validate type and convert string to boolean if necessary
|
|
110 if is_string($enable_ntp) {
|
|
111 $ntp_enabled = str2bool($enable_ntp)
|
|
112 } else {
|
|
113 $ntp_enabled = $enable_ntp
|
|
114 }
|
|
115 if $ntp_enabled == true {
|
|
116 include ::ntp
|
|
117 }
|
|
118
|
|
119 # validate type and convert string to boolean if necessary
|
|
120 if is_string($enable_pam) {
|
|
121 $pam_enabled = str2bool($enable_pam)
|
|
122 } else {
|
|
123 $pam_enabled = $enable_pam
|
|
124 }
|
|
125 if $pam_enabled == true {
|
|
126 include ::pam
|
|
127 }
|
|
128
|
|
129 # validate type and convert string to boolean if necessary
|
|
130 if is_string($enable_puppet_agent) {
|
|
131 $puppet_agent_enabled = str2bool($enable_puppet_agent)
|
|
132 } else {
|
|
133 $puppet_agent_enabled = $enable_puppet_agent
|
|
134 }
|
|
135 if $puppet_agent_enabled == true {
|
|
136 include ::puppet::agent
|
|
137 }
|
|
138
|
|
139 # validate type and convert string to boolean if necessary
|
|
140 if is_string($enable_rsyslog) {
|
|
141 $rsyslog_enabled = str2bool($enable_rsyslog)
|
|
142 } else {
|
|
143 $rsyslog_enabled = $enable_rsyslog
|
|
144 }
|
|
145 if $rsyslog_enabled == true {
|
|
146 include ::rsyslog
|
|
147 }
|
|
148
|
|
149 # validate type and convert string to boolean if necessary
|
|
150 if is_string($enable_selinux) {
|
|
151 $selinux_enabled = str2bool($enable_selinux)
|
|
152 } else {
|
|
153 $selinux_enabled = $enable_selinux
|
|
154 }
|
|
155 if $selinux_enabled == true {
|
|
156 include ::selinux
|
|
157 }
|
|
158
|
|
159 # validate type and convert string to boolean if necessary
|
|
160 if is_string($enable_ssh) {
|
|
161 $ssh_enabled = str2bool($enable_ssh)
|
|
162 } else {
|
|
163 $ssh_enabled = $enable_ssh
|
|
164 }
|
|
165 if $ssh_enabled == true {
|
|
166 include ::ssh
|
|
167 }
|
|
168
|
|
169 # validate type and convert string to boolean if necessary
|
|
170 if is_string($enable_utils) {
|
|
171 $utils_enabled = str2bool($enable_utils)
|
|
172 } else {
|
|
173 $utils_enabled = $enable_utils
|
|
174 }
|
|
175 if $utils_enabled == true {
|
|
176 include ::utils
|
|
177 }
|
|
178
|
|
179 # validate type and convert string to boolean if necessary
|
|
180 if is_string($enable_vim) {
|
|
181 $vim_enabled = str2bool($enable_vim)
|
|
182 } else {
|
|
183 $vim_enabled = $enable_vim
|
|
184 }
|
|
185 if $vim_enabled == true {
|
|
186 include ::vim
|
|
187 }
|
|
188
|
|
189 # validate type and convert string to boolean if necessary
|
|
190 if is_string($enable_wget) {
|
|
191 $wget_enabled = str2bool($enable_wget)
|
|
192 } else {
|
|
193 $wget_enabled = $enable_wget
|
|
194 }
|
|
195 if $wget_enabled == true {
|
|
196 include ::wget
|
|
197 }
|
|
198
|
|
199 # only allow supported OS's
|
|
200 case $::osfamily {
|
|
201 'debian': {
|
|
202 # validate type and convert string to boolean if necessary
|
|
203 if is_string($enable_debian) {
|
|
204 $debian_enabled = str2bool($enable_debian)
|
|
205 } else {
|
|
206 $debian_enabled = $enable_debian
|
|
207 }
|
|
208 if $debian_enabled == true {
|
|
209 include ::debian
|
|
210 }
|
|
211 }
|
|
212 'redhat': {
|
|
213 # validate type and convert string to boolean if necessary
|
|
214 if is_string($enable_redhat) {
|
|
215 $redhat_enabled = str2bool($enable_redhat)
|
|
216 } else {
|
|
217 $redhat_enabled = $enable_redhat
|
|
218 }
|
|
219 if $redhat_enabled == true {
|
|
220 include ::redhat
|
|
221 }
|
|
222 }
|
|
223 'solaris': {
|
|
224 # validate type and convert string to boolean if necessary
|
|
225 if is_string($enable_solaris) {
|
|
226 $solaris_enabled = str2bool($enable_solaris)
|
|
227 } else {
|
|
228 $solaris_enabled = $enable_solaris
|
|
229 }
|
|
230 if $solaris_enabled == true {
|
|
231 include ::solaris
|
|
232 }
|
|
233 }
|
|
234 'suse': {
|
|
235 # validate type and convert string to boolean if necessary
|
|
236 if is_string($enable_suse) {
|
|
237 $suse_enabled = str2bool($enable_suse)
|
|
238 } else {
|
|
239 $suse_enabled = $enable_suse
|
|
240 }
|
|
241 if $suse_enabled == true {
|
|
242 include ::suse
|
|
243 }
|
|
244 }
|
|
245 default: {
|
|
246 fail("Supported OS families are Debian, RedHat, Solaris, and Suse. Detected osfamily is ${::osfamily}.")
|
|
247 }
|
|
248 }
|
|
249
|
|
250 # validate type and convert string to boolean if necessary
|
|
251 if is_string($manage_root_password) {
|
|
252 $manage_root_password_real = str2bool($manage_root_password)
|
|
253 } else {
|
|
254 $manage_root_password_real = $manage_root_password
|
|
255 }
|
|
256
|
|
257 if $manage_root_password_real == true {
|
|
258
|
|
259 # validate root_password - fail if not a string
|
|
260 if !is_string($root_password) {
|
|
261 fail('common::root_password is not a string.')
|
|
262 }
|
|
263
|
|
264 user { 'root':
|
|
265 password => $root_password,
|
|
266 }
|
|
267 }
|
|
268
|
|
269 # validate type and convert string to boolean if necessary
|
|
270 if is_string($create_opt_lsb_provider_name_dir) {
|
|
271 $create_opt_lsb_provider_name_dir_real = str2bool($create_opt_lsb_provider_name_dir)
|
|
272 } else {
|
|
273 $create_opt_lsb_provider_name_dir_real = $create_opt_lsb_provider_name_dir
|
|
274 }
|
|
275
|
|
276 if $create_opt_lsb_provider_name_dir_real == true {
|
|
277
|
|
278 # validate lsb_provider_name - fail if not a string
|
|
279 if !is_string($lsb_provider_name) {
|
|
280 fail('common::lsb_provider_name is not a string.')
|
|
281 }
|
|
282
|
|
283 if $lsb_provider_name != 'UNSET' {
|
|
284
|
|
285 # basic filesystem requirements
|
|
286 file { "/opt/${lsb_provider_name}":
|
|
287 ensure => directory,
|
|
288 owner => 'root',
|
|
289 group => 'root',
|
|
290 mode => '0755',
|
|
291 }
|
|
292 }
|
|
293 }
|
|
294
|
|
295 if $users != undef {
|
|
296
|
|
297 # Create virtual user resources
|
|
298 create_resources('@common::mkuser',$common::users)
|
|
299
|
|
300 # Collect all virtual users
|
|
301 Common::Mkuser <||> # lint:ignore:spaceship_operator_without_tag
|
|
302 }
|
|
303
|
|
304 if $groups != undef {
|
|
305
|
|
306 # Create virtual group resources
|
|
307 create_resources('@group',$common::groups)
|
|
308
|
|
309 # Collect all virtual groups
|
|
310 Group <||> # lint:ignore:spaceship_operator_without_tag
|
|
311 }
|
|
312 }
|