Mount NFS share defined in hiera

29 views
Skip to first unread message

Laci D

unread,
Feb 23, 2023, 2:56:44 PM2/23/23
to Puppet Users
I'm looking for manifest, hiera example which can mount an NFS defined in a hiera_hash.

Someone must have one, thank you!

Chris Ritson

unread,
Feb 24, 2023, 6:31:03 AM2/24/23
to puppet...@googlegroups.com

The code I have been given for an NFS mount is like this. Note the module in use on the first line….

 

types::files:

  # derdanne/nfs takes care of mountpoint creation.

  '<mountpoint>’:

    ensure: directory

    mode: '0775'

 

debconfs:

  'apparmor/homedirs':

    ensure: present

    type: string

    value: <mount point subdir with homes>

    seen: 'true'

    notify: Exec[dr_apparmor]

 

nfs::client_enabled:      true

nfs::manage_packages:     true

nfs::nfs_v4_client:       false

 

nfs_client_mounts:

  <mount point>:

    server: <server name>

    share:  <server share>

 

--

Chris Ritson (School of Computing)

Newcastle University, NE1 7RU

Tel: +44(0)1912080073

 

From: puppet...@googlegroups.com <puppet...@googlegroups.com>
Sent: 24 February 2023 11:13
To: Digest recipients <puppet...@googlegroups.com>
Subject: [Puppet Users] Digest for puppet...@googlegroups.com - 1 update in 1 topic

 

External sender. Take care when opening links or attachments. Do not provide your login details.


I'm looking for manifest, hiera example which can mount an NFS defined in
a hiera_hash.
 
Someone must have one, thank you!

You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to puppet-users...@googlegroups.com.

 

Laci D

unread,
Feb 24, 2023, 12:14:46 PM2/24/23
to Puppet Users
Thank you!

My situation was a bit more complicated since needed support for two operating systems, the following implementation worked:

common.yaml
nfs_mounts:    
     device: 'nfs.server.com:/mount'
    options: 'nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport'



manifests/profiles/nfs_home.pp
class site::profiles::nfs_home {
 $nfs_mounts_hiera = hiera_hash('nfs_mounts')

   case $::operatingsystem {
           'ubuntu': {
              mount { "/nfs_mount":
                   device  => $nfs_mounts_hiera['device'],
                   fstype  => "nfs4",
                   ensure  => "mounted",
                   options => $nfs_mounts_hiera['options'],
                   atboot  => true,
               }
           }
          'freebsd': {
               mounttab { "/nfs_mount":
                   device  => $nfs_mounts_hiera['device'],
                   fstype  => "nfs4",
                   ensure  => "present",
                   options => "rw",
                   target => "/etc/fstab",

               }

           }
       }

   }
Reply all
Reply to author
Forward
0 new messages