Puppet Class: nfs::config::nfs_conf

Inherits:
nfs
Defined in:
manifests/config/nfs_conf.pp

Summary

Write out the nfs services config for client and server

Overview

/etc/nfs.conf is where NFS services get most of their info

Parameters:

  • use_gssproxy (Any) (defaults to: $nfs::use_gssproxy)

    Boolean, should GSSProxy be configured (via the gssproxy module)

  • gssproxy_services (Any) (defaults to: $nfs::gssproxy_services)

    Hash of GSSProxy services to define

  • server_nfsv3_support (Any) (defaults to: $nfs::server_nfsv3_support)

    Boolean, should NFS server have NFSv3 support

  • server_nfsv4_support (Any) (defaults to: $nfs::server_nfsv4_support)

    Boolean, should NFS server have NFSv4 support

  • client_kerberos_support (Any) (defaults to: $nfs::client_kerberos_support)

    Boolean, should NFS client have kerberos support

  • server_kerberos_support (Any) (defaults to: $nfs::server_kerberos_support)

    Boolean, should NFS server have kerberos support

  • nfs_conf_file (Any) (defaults to: $nfs::nfs_conf_file)

    Path to your /etc/nfs.conf

  • nfs_conf_d (Any) (defaults to: $nfs::nfs_conf_d)

    Path to your /etc/nfs.conf.d

  • purge_unmanaged_nfs_conf_d (Any) (defaults to: $nfs::purge_unmanaged_nfs_conf_d)

    Boolean, remove any unmanaged files in /etc/nfs.conf.d

  • nfs_conf_hash (Any) (defaults to: $nfs::nfs_conf_hash)

    Hash of settings you want in /etc/nfs.conf

  • vendor_nfs_conf_hash (Any) (defaults to: $nfs::vendor_nfs_conf_hash)

    Hash of vendor default settings in /etc/nfs.conf



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
# File 'manifests/config/nfs_conf.pp', line 30

class nfs::config::nfs_conf (
  $use_gssproxy = $nfs::use_gssproxy,
  $gssproxy_services = $nfs::gssproxy_services,
  $server_nfsv3_support = $nfs::server_nfsv3_support,
  $server_nfsv4_support = $nfs::server_nfsv4_support,
  $client_kerberos_support = $nfs::client_kerberos_support,
  $server_kerberos_support = $nfs::server_kerberos_support,
  $nfs_conf_file = $nfs::nfs_conf_file,
  $nfs_conf_d = $nfs::nfs_conf_d,
  $purge_unmanaged_nfs_conf_d = $nfs::purge_unmanaged_nfs_conf_d,
  $nfs_conf_hash = $nfs::nfs_conf_hash,
  $vendor_nfs_conf_hash = $nfs::vendor_nfs_conf_hash,
) inherits nfs {
  assert_private()

  $merged_nfs_conf_hash = deep_merge($vendor_nfs_conf_hash, $nfs_conf_hash)
  if $server_nfsv3_support {
    $merged_nfs_conf_hash_v3setting = deep_merge($merged_nfs_conf_hash, {'nfsd' => {'vers3' => 'yes'}})
  } else {
    $merged_nfs_conf_hash_v3setting = deep_merge($merged_nfs_conf_hash, {'nfsd' => {'vers3' => 'no'}})
  }
  if $server_nfsv4_support {
    $merged_nfs_conf_hash_v4setting = deep_merge($merged_nfs_conf_hash_v3setting, {'nfsd' => {'vers4' => 'yes'}})
  } else {
    $merged_nfs_conf_hash_v4setting = deep_merge($merged_nfs_conf_hash_v3setting, {'nfsd' => {'vers4' => 'no'}})
  }
  if $use_gssproxy {
    unless $client_kerberos_support or $server_kerberos_support {
      fail('Requested GSSProxy support, but did not enable kerberos for client or server')
    }

    contain 'nfs::config::gssproxy'

    $merged_nfs_conf_hash_gssproxy = deep_merge($merged_nfs_conf_hash_v4setting, {'gssd' => {'use-gss-proxy' => 'yes'}})
  } else {
    $merged_nfs_conf_hash_gssproxy = deep_merge($merged_nfs_conf_hash_v4setting, {'gssd' => {'use-gss-proxy' => 'no'}})
  }

  $nfs_conf_template_params = {
    'nfs_conf' => $merged_nfs_conf_hash_gssproxy,
  }

  file { $nfs_conf_file:
    ensure  => 'present',
    owner   => 'root',
    group   => 'root',
    mode    => '0644',
    content => epp('nfs/etc/nfs_conf.epp', $nfs_conf_template_params),
  }

  file { $nfs_conf_d:
    ensure  => 'directory',
    owner   => 'root',
    group   => 'root',
    mode    => '0755',
    recurse => $purge_unmanaged_nfs_conf_d,
    purge   => $purge_unmanaged_nfs_conf_d,
  }

  if $facts['os']['family'] == 'RedHat' and $facts['os']['release']['major'] == 7 {
    if $use_gssproxy {
      $gss_use_proxy = 'yes'
      $secure_nfs = 'yes'
    } else {
      $gss_use_proxy = 'no'

      if $client_kerberos_support or $server_kerberos_support {
        $secure_nfs = 'yes'
      } else {
        $secure_nfs = 'no'
      }
    }

    file { '/etc/sysconfig/nfs':
      ensure  => 'present',
      owner   => 'root',
      group   => 'root',
      mode    => '0644',
      content => epp('nfs/etc/sysconfig/nfs.epp', { 'secure_nfs' => $secure_nfs, 'gss_use_proxy' => $gss_use_proxy }),
    }
  }
}