Puppet Function: complyadm::get_yaml_key_value
- Defined in:
- lib/puppet/functions/complyadm/get_yaml_key_value.rb
- Function type:
- Ruby 4.x API
Overview
Gets a single entry from the stored yaml
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/complyadm/get_yaml_key_value.rb', line 5 Puppet::Functions.create_function(:'complyadm::get_yaml_key_value') do # @param data A hash to write as yaml # @return value if exists, else nil dispatch :get_yaml_key_value do param 'String', :key param 'String', :relative_file_path return_type 'String' end def get_yaml_key_value(key, relative_file_path) boltdir = call_function('complyadm::bolt_project_dir') abs_file_path = File.(relative_file_path, boltdir) value = '' if File.file?(abs_file_path) data = YAML.load_file abs_file_path if data['complyadm::config'].key?(key) value=data['complyadm::config'][key] end end value end end |