Puppet Function: simplib::module_exist
- Defined in:
- lib/puppet/functions/simplib/module_exist.rb
- Function type:
- Ruby 4.x API
Overview
Determines if a module exists in the current environment
If passed with an author, such as ‘simp/simplib` or `simp-simplib`, will return whether or not that specific module exists.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/puppet/functions/simplib/module_exist.rb', line 5 Puppet::Functions.create_function(:'simplib::module_exist') do # @param module_name The module name to check # @return [Boolean] Whether or not the module exists in the current environment dispatch :module_exist do required_param 'String[1]', :module_name end def module_exist(module_name) , name = module_name.split(%r{/|-}) unless name name = .dup = nil end return false unless Puppet::Module.find(name, closure_scope.compiler.environment.to_s) return true unless return true if .strip == call_function('load_module_metadata', name)['name'].strip.split(%r{/|-}).first false end end |