Puppet Class: nfs::params

Inherited by:
nfs
Defined in:
manifests/params.pp

Summary

Overview

Class: nfs::params

This class exists to

  1. Declutter the default value assignment for class parameters.

  2. Manage internally used module variables in a central place.

Therefore, many operating system dependent differences (names, paths, …) are addressed in here.

Author:



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
# File 'manifests/params.pp', line 15

class nfs::params {
  #### Default values for the parameters of the main module class, init.pp

  if $facts['networking']['domain'] != undef {
    $nfs_v4_idmap_domain = $facts['networking']['domain']
  } else {
    $nfs_v4_idmap_domain = 'example.org'
  }

  # Different path and package definitions
  case $facts['os']['family'] {
    'Debian': {
      $exports_file          = '/etc/exports'
      $idmapd_file           = '/etc/idmapd.conf'
      $defaults_file         = '/etc/default/nfs-common'
      $server_packages       = ['nfs-common', 'nfs-kernel-server', 'nfs4-acl-tools', 'rpcbind']
      $client_packages       = ['nfs-common', 'nfs4-acl-tools', 'rpcbind']
      $client_rpcbind_config = '/etc/default/rpcbind'
    }
    'RedHat': {
      $exports_file          = '/etc/exports'
      $idmapd_file           = '/etc/idmapd.conf'
      $defaults_file         = '/etc/sysconfig/nfs'
      $server_packages       = ['nfs-utils', 'nfs4-acl-tools', 'rpcbind']
      $client_packages       = ['nfs-utils', 'nfs4-acl-tools', 'rpcbind']
      $client_rpcbind_config = '/etc/sysconfig/rpcbind'
    }
    'Gentoo': {
      $exports_file          = '/etc/exports'
      $idmapd_file           = '/etc/idmapd.conf'
      $defaults_file         = '/etc/conf.d/nfs'
      $server_packages       = ['net-nds/rpcbind', 'net-fs/nfs-utils', 'net-libs/libnfsidmap']
      $client_packages       = ['net-nds/rpcbind', 'net-fs/nfs-utils', 'net-libs/libnfsidmap']
      $client_rpcbind_config = undef
    }
    'Suse': {
      $exports_file          = '/etc/exports'
      $idmapd_file           = '/etc/idmapd.conf'
      $server_packages       = ['nfs-kernel-server']
      $client_packages       = ['nfsidmap', 'nfs-client', 'rpcbind']
      $defaults_file         = undef
      $client_rpcbind_config = undef
    }
    'Archlinux': {
      $exports_file          = '/etc/exports'
      $idmapd_file           = '/etc/idmapd.conf'
      $server_packages       = ['nfs-utils']
      $client_packages       = ['nfs-utils', 'nfsidmap', 'rpcbind']
      $defaults_file         = undef
      $client_rpcbind_config = undef
    }
    default: {
      $exports_file          = undef
      $idmapd_file           = undef
      $defaults_file         = undef
      $server_packages       = undef
      $client_packages       = undef
      $client_rpcbind_config = undef
      notice("\"${module_name}\" provides no config directory and package default values for OS family \"${facts['os']['family']}\"")
    }
  }

  # service parameters
  # params that are the same on all (known) OSes.
  $client_nfs_fstype          = 'nfs'
  $client_services_hasrestart = true
  $client_services_hasstatus  = true
  $client_gssd_options        = ''
  $server_service_hasrestart  = true
  $server_service_hasstatus   = true
  $server_service_restart_cmd = undef
  #params with OS-specific values
  case $facts['os']['family'] {
    'Debian': {
      $client_idmapd_setting      = ['set NEED_IDMAPD yes']
      $client_nfs_options         = 'tcp,nolock,rsize=32768,wsize=32768,intr,noatime,nfsvers=3,actimeo=3'
      $client_services_enable     = true
      $client_nfsv4_fstype        = 'nfs4'
      $client_nfsv4_options       = 'tcp,nolock,rsize=32768,wsize=32768,intr,noatime,actimeo=3'
      $nfs_v4_idmap_nobody_user   = 'nobody'
      $nfs_v4_idmap_nobody_group  = 'nogroup'
      $client_rpcbind_optname     = 'OPTIONS'

      case $facts['os']['distro']['codename'] {
        'bullseye': {
          $client_services            = { 'rpcbind' => {
              ensure => 'running',
              enable => false,
            },
          }
          $client_gssd_service_name   = { 'rpc-gssd' => {
              ensure => 'running',
              enable => true,
            },
          }
          $client_nfsv4_services      = { 'rpcbind' => {
              ensure => 'running',
              enable => false,
            },
          }
          $server_nfsv4_servicehelper = ['nfs-idmapd']
          $server_service_name        = 'nfs-kernel-server'
          $client_gssdopt_name        = 'GSSDARGS'
        }
        'focal', 'jammy': {
          $client_services            = { 'rpcbind' => {} }
          $client_gssd_service_name   = { 'rpc-gssd' => {
              ensure => 'running',
              enable => true,
            },
          }
          $client_nfsv4_services      = { 'rpcbind' => {} }
          $server_nfsv4_servicehelper = undef
          $server_service_name        = 'nfs-kernel-server'
          $client_gssdopt_name        = 'GSSDARGS'
        }
        default: {
          $client_services            = { 'rpcbind' => {} }
          $client_gssd_service_name   = { 'rpc-gssd' => {
              ensure => 'running',
              enable => true,
            },
          }
          $client_nfsv4_services      = { 'rpcbind' => {} }
          $server_nfsv4_servicehelper = ['idmapd']
          $server_service_name        = 'nfs-kernel-server'
          $client_gssdopt_name        = 'GSSDARGS'
        }
      }
    }
    'RedHat': {
      $nfs_v4_idmap_nobody_user   = 'nobody'
      $nfs_v4_idmap_nobody_group  = 'nobody'
      $client_rpcbind_optname     = 'RPCBIND_ARGS'
      case $facts['os']['release']['major'] {
        '7': {
          $client_idmapd_setting      = ['']
          $client_nfs_options         = 'tcp,nolock,rsize=32768,wsize=32768,intr,noatime,nfsvers=3,actimeo=3'
          $client_services_enable     = true
          $client_gssdopt_name        = 'RPCGSSDARGS'
          if versioncmp($facts['os']['release']['full'], '7.5') < 0 {
            $client_services            = { 'rpcbind.service' => {
                ensure => 'running',
                enable => false,
              },
              'rpcbind.socket' => {
                ensure => 'running',
                enable => true,
              },
            }
          }
          else {
            $client_services            = { 'rpcbind.service' => {} }
          }
          $client_gssd_service_name   = { 'rpc-gssd' => {
              ensure => 'running',
              enable => true,
            },
          }
          $client_nfsv4_fstype        = 'nfs4'
          $client_nfsv4_options       = 'tcp,nolock,rsize=32768,wsize=32768,intr,noatime,actimeo=3'
          if versioncmp($facts['os']['release']['full'], '7.5') < 0 {
            $client_nfsv4_services      = { 'rpcbind.service' => {
                ensure => 'running',
                enable => false,
              },
              'rpcbind.socket' => {
                ensure => 'running',
                enable => true,
              },
            }
          }
          else {
            $client_nfsv4_services      = { 'rpcbind' => {} }
          }
          $server_nfsv4_servicehelper = ['nfs-idmap.service']
          $server_service_name        = 'nfs-server.service'
        }
        '8': {
          $client_idmapd_setting      = ['']
          $client_nfs_options         = 'tcp,nolock,rsize=32768,wsize=32768,intr,noatime,actimeo=3'
          $client_services_enable     = true
          $client_gssdopt_name        = 'RPCGSSDARGS'
          $client_services            = { 'rpcbind.service' => {} }
          $client_gssd_service_name   = { 'rpc-gssd' => {
              ensure => 'running',
              enable => true,
            },
          }
          $client_nfsv4_fstype        = 'nfs4'
          $client_nfsv4_options       = 'tcp,nolock,rsize=32768,wsize=32768,intr,noatime,actimeo=3'
          $client_nfsv4_services      = { 'rpcbind' => {} }
          $server_nfsv4_servicehelper = ['nfs-idmapd.service']
          $server_service_name        = 'nfs-server.service'
        }
        '9': {
          $client_idmapd_setting      = ['']
          $client_nfs_options         = 'tcp,nolock,rsize=32768,wsize=32768,intr,noatime,actimeo=3'
          $client_services_enable     = true
          $client_gssdopt_name        = 'RPCGSSDARGS'
          $client_services            = { 'rpcbind.service' => {} }
          $client_gssd_service_name   = { 'rpc-gssd' => {
              ensure => 'running',
              enable => true,
            },
          }
          $client_nfsv4_fstype        = 'nfs4'
          $client_nfsv4_options       = 'tcp,nolock,rsize=32768,wsize=32768,intr,noatime,actimeo=3'
          $client_nfsv4_services      = { 'rpcbind' => {} }
          $server_nfsv4_servicehelper = ['nfs-idmapd.service']
          $server_service_name        = 'nfs-server.service'
        }
        default: {
          $client_gssdopt_name        = 'RPCGSSDARGS'
          $client_idmapd_setting      = ['']
          $client_nfs_options         = 'tcp,nolock,rsize=32768,wsize=32768,intr,noatime,actimeo=3'
          $client_services_enable     = true
          $client_services            = { 'rpcbind' => {} }
          $client_gssd_service_name   = { 'rpc-gssd' => {
              ensure => 'running',
              enable => true,
            },
          }
          $client_nfsv4_fstype        = 'nfs4'
          $client_nfsv4_options       = 'tcp,nolock,rsize=32768,wsize=32768,intr,noatime,actimeo=3'
          $client_nfsv4_services      = { 'rpcbind' => {}, 'rpcidmapd' => {} }
          $server_nfsv4_servicehelper = ['rpcidmapd', 'rpcbind']
          $server_service_name        = 'nfs'
        }
      }
    }
    'Gentoo': {
      $nfs_v4_idmap_nobody_user   = 'nobody'
      $nfs_v4_idmap_nobody_group  = 'nogroup'
      $client_rpcbind_optname     = 'OPTS_RPC_NFSD'
      $client_gssdopt_name        = 'RPCGSSDARGS'
      $client_idmapd_setting      = ['set NFS_NEEDED_SERVICES rpc.idmapd']
      $client_nfs_options         = 'tcp,nolock,rsize=32768,wsize=32768,intr,noatime,nfsvers=3,actimeo=3'
      $client_services_enable     = true
      $client_services            = { 'rpcbind' => {} }
      $client_gssd_service_name   = undef
      $client_nfsv4_fstype        = 'nfs4'
      $client_nfsv4_options       = 'tcp,nolock,rsize=32768,wsize=32768,intr,noatime,nfsvers=4,actimeo=3'
      $client_nfsv4_services      = { 'rpcbind' => {}, 'rpc.idmapd' => {} }
      $server_nfsv4_servicehelper = ['rpc.idmapd']
      $server_service_name        = 'nfs'
    }
    'Suse': {
      $nfs_v4_idmap_nobody_user   = 'nobody'
      $nfs_v4_idmap_nobody_group  = 'nobody'
      $client_rpcbind_optname     = 'RPCNFSDARGS'
      $client_gssdopt_name        = 'GSSD_OPTIONS'
      $client_idmapd_setting      = ['']
      $client_nfs_options         = 'tcp,nolock,rsize=32768,wsize=32768,intr,noatime,nfsvers=3,actimeo=3'
      $client_services_enable     = true
      $client_services            = { 'rpcbind' => { before => Service['nfs'] }, 'nfs' => {} }
      $client_gssd_service_name   = undef
      $client_nfsv4_fstype        = 'nfs4'
      $client_nfsv4_options       = 'tcp,nolock,rsize=32768,wsize=32768,intr,noatime,nfsvers=4,actimeo=3'
      $client_nfsv4_services      = { 'rpcbind' => { before => Service['nfs'] }, 'nfs' => {} }
      $server_nfsv4_servicehelper = undef
      $server_service_name        = 'nfsserver'
    }
    'Archlinux': {
      $nfs_v4_idmap_nobody_user   = 'nobody'
      $nfs_v4_idmap_nobody_group  = 'nobody'
      $client_rpcbind_optname     = 'RPCNFSDARGS'
      $client_gssdopt_name        = 'RPCGSSDARGS'
      $client_idmapd_setting      = ['']
      $client_nfs_options         = 'tcp,nolock,rsize=32768,wsize=32768,intr,noatime,nfsvers=3,actimeo=3'
      $client_services_enable     = true
      $client_services            = { 'rpcbind' => {} }
      $client_gssd_service_name   = undef
      $client_nfsv4_fstype        = 'nfs4'
      $client_nfsv4_options       = 'tcp,nolock,rsize=32768,wsize=32768,intr,noatime,nfsvers=4,actimeo=3'
      $client_nfsv4_services      = { 'rpcbind' => {} }
      $server_nfsv4_servicehelper = ['nfs-idmapd']
      $server_service_name        = 'nfs-server.service'
    }
    default: {
      # need to explicitly set unknown params to undef to work with strict_variables=true
      $nfs_v4_idmap_nobody_user   = undef
      $nfs_v4_idmap_nobody_group  = undef
      $client_rpcbind_optname     = undef
      $client_gssdopt_name        = undef
      $client_idmapd_setting      = undef
      $client_nfs_options         = undef
      $client_nfsv4_fstype        = undef
      $client_nfsv4_options       = undef
      $client_nfsv4_services      = undef
      $client_gssd_service_name   = undef
      $server_nfsv4_servicehelper = undef
      $client_services_enable     = undef
      $server_service_name        = undef
      notice("\"${module_name}\" provides no service parameters for OS family \"${facts['os']['family']}\"")
    }
  }
}