Defined Type: psick::nfs::export

Defined in:
manifests/nfs/export.pp

Overview

Define: psick::nfs::export

Manages nfs exports either via concat on /etc/exports or with files in /etc/exports.d/ (if $use_exportsd is set to true)

Parameters:

  • ensure (Enum[present,absent]) (defaults to: 'present')
  • share (String) (defaults to: '/srv/nfs')
  • guest (String) (defaults to: '127.0.0.1')
  • options (String) (defaults to: '')
  • content (String) (defaults to: '')
  • use_exportsd (Boolean) (defaults to: false)


5
6
7
8
9
10
11
12
13
14
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
# File 'manifests/nfs/export.pp', line 5

define psick::nfs::export (
  Enum[present,absent] $ensure  = 'present',

  String $share                 = '/srv/nfs',

  String $guest                 = '127.0.0.1',
  String $options               = '', # lint:ignore:params_empty_string_assignment

  String $content               = '', # lint:ignore:params_empty_string_assignment

  Boolean $use_exportsd         = false,
) {
  if $options != '' {
    $auto_content = "${share} ${guest}(${options})\n"
  } else {
    $auto_content = "${share} ${guest}\n"
  }
  $real_content = $content ? {
    ''      => $auto_content,
    default => $content,
  }
  $safe_name = regsubst($name, '/', '_', 'G')

  if $use_exportsd {
    file { "/etc/exports.d/${safe_name}.export":
      content => $real_content,
      notify  => Exec['exportfs -a'],
    }
  } else {
    if !defined(Concat['/etc/exports']) {
      concat { '/etc/exports':
        ensure => $ensure,
        mode   => '0644',
        owner  => 'root',
        group  => 'root',
        notify => Exec['exportfs -a'],
      }
    }
    concat::fragment { "/etc/exports_${title}":
      target  => '/etc/exports',
      content => $real_content,
      notify  => Exec['exportfs -a'],
    }
  }

  if !defined(Exec['exportfs -a']) {
    exec { 'exportfs -a':
      refreshonly => true,
      path        => $facts['path'],
    }
  }

  if !defined(Exec["mkdir -p ${share}"]) {
    exec { "mkdir -p ${share}":
      creates => $share,
      path    => $facts['path'],
    }
  }
}