Puppet Function: mount_nfs_volume

Defined in:
modules/labstore/lib/puppet/parser/functions/mount_nfs_volume.rb
Function type:
Ruby 3.x API

Overview

mount_nfs_volume()Any

Returns:

  • (Any)


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'modules/labstore/lib/puppet/parser/functions/mount_nfs_volume.rb', line 13

newfunction(:mount_nfs_volume, :type => :rvalue, :arity => 2) do |args|
  module_path = function_get_module_path(['labstore'])
  path = "#{module_path}/templates/nfs-mounts.yaml.erb"
  mtime = File.stat(path).mtime
  if @@labs_nfs_config_touched.nil? || mtime != @@labs_nfs_config_touched
      require 'yaml'
      mount_yaml = function_template([path])
      @@labs_nfs_config = YAML.safe_load(mount_yaml)
      @@labs_nfs_config_touched = mtime
  end
  config = @@labs_nfs_config['private']
  project = args[0]
  mount = args[1]
  if config.key?(project) && config[project].key?('mounts') \
      && config[project]['mounts'].key?(mount)
    config[project]['mounts'][mount]
  else
    false
  end
end