Puppet Function: complyadm::save_yaml_key_value
- Defined in:
- lib/puppet/functions/complyadm/save_yaml_key_value.rb
- Function type:
- Ruby 4.x API
Overview
Takes a hash object, calls .to_yaml and saves it to disk
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/save_yaml_key_value.rb', line 5 Puppet::Functions.create_function(:'complyadm::save_yaml_key_value') do # @param data A hash to write as yaml # @param relative_file_path path relative to the bolt project # @return true dispatch :save_yaml_key_value do param 'String', :key param 'String', :value param 'String', :relative_file_path return_type 'Boolean' end def save_yaml_key_value(key, value, relative_file_path) boltdir = call_function('complyadm::bolt_project_dir') abs_file_path = File.(relative_file_path, boltdir) data = YAML.load_file abs_file_path data['complyadm::config'][key] = value File.open(abs_file_path, 'w') do |file| file.write data.to_yaml end true end end |