Skip to content

Instantly share code, notes, and snippets.

@cwage

cwage/- Secret

Created May 5, 2017 19:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cwage/91d4add53aff6eb1e738ed4dc099e19e to your computer and use it in GitHub Desktop.
Save cwage/91d4add53aff6eb1e738ed4dc099e19e to your computer and use it in GitHub Desktop.
Example hiera:
osp::devo::nfs::exports:
osky_web_data:
path: /mnt/osky_web_data
clients:
phpnodes:
192.168.60.0/24(ro)
osky_web_cache:
path: /mnt/osky_web_cache
clients:
phpnodes:
192.168.60.0/24(rw)
in my class:
$exports = hiera('osp::devo::nfs::exports')
$exports.each |String $export, Hash $export_hash| {
file { $export_hash['path']:
ensure => 'directory'
}
# .. etc
}
@jfryman
Copy link

jfryman commented May 5, 2017

osp::devo::nfs::exports:
  - osky_web_data:
      path: /mnt/osky_web_data
      clients:
        phpnodes:
          192.168.60.0/24(ro)
  - osky_web_cache:
      path: /mnt/osky_web_cache
      clients:
        phpnodes:
          192.168.60.0/24(rw)

@cwage
Copy link
Author

cwage commented May 5, 2017

==> devo_nfs:           Found key: "osp::devo::nfs::exports" value: [
==> devo_nfs:             {
==> devo_nfs:               "osky_web_data" => {
==> devo_nfs:                 "path" => "/mnt/osky_web_data",
==> devo_nfs:                 "clients" => {
==> devo_nfs:                   "192.168.60.0/24" => "ro",
==> devo_nfs:                   "10.0.0.0/8" => "rw"
==> devo_nfs:                 }
==> devo_nfs:               }
==> devo_nfs:             },
==> devo_nfs:             {
==> devo_nfs:               "osky_web_cache" => {
==> devo_nfs:                 "path" => "/mnt/osky_web_cache",
==> devo_nfs:                 "clients" => {
==> devo_nfs:                   "192.168.60.0/24" => "rw"
==> devo_nfs:                 }
==> devo_nfs:               }
==> devo_nfs:             }
==> devo_nfs:           ]

@cwage
Copy link
Author

cwage commented May 5, 2017

osp::devo::nfs::exports:
    - path: /mnt/osky_web_data
      clients:
        "192.168.60.0/24": ro
        "10.0.0.0/8": rw
    - path: /mnt/osky_web_cache
      clients:
        "192.168.60.0/24": rw

@cwage
Copy link
Author

cwage commented May 5, 2017

class ospw_devo::profiles::nfs::server() {

  $exports = hiera('osp::devo::nfs::exports')

  class { 'nfs::server':
    nfs_v4                     => true,
    nfs_v4_export_root_clients =>
    '*(rw,fsid=root,insecure,no_subtree_check,async,no_root_squash)'
  }

  $exports.each |Hash $export| {
    file { $export['path']:
      ensure => 'directory'
      } ->

      nfs::server::export{ $export['path']:
        ensure  => 'mounted',
        clients => mk_client_list(keys($export['clients']), $export['clients'], '')
      }
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment