Puppet Class: hashfile

Defined in:
manifests/init.pp

Summary

Create various file formats from a source hash

Overview

Examples:

Hiera representation of an INI file from a hash

hashfile::ini:
  /tmp/file.ini:
    file:
      ensure: file
      owner: root
      group: root
      mode: '0600'
    data:
      section1:
        key1: value1
        key2: value2

Parameters:

  • ini (Hash) (defaults to: {})

    A data hash to be converted to ini files

  • json (Hash) (defaults to: {})

    A data hash to be converted to json files

  • kv (Hash) (defaults to: {})

    A data hash to be converted to key/value (shellvar) files

  • properties (Hash) (defaults to: {})

    A data hash to be converted to Java properties files

  • yaml (Hash) (defaults to: {})

    A data hash to be converted to yaml files



26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'manifests/init.pp', line 26

class hashfile  (
  Hash $ini = {},
  Hash $json = {},
  Hash $kv = {},
  Hash $properties = {},
  Hash $yaml = {},
) {
  # Create resources from parameter hashes using the defined types
  $ini.each        |$name, $hash| { Resource['Hashfile::Ini']        { $name: * => $hash, } }
  $json.each       |$name, $hash| { Resource['Hashfile::Json']       { $name: * => $hash, } }
  $kv.each         |$name, $hash| { Resource['Hashfile::Kv']         { $name: * => $hash, } }
  $properties.each |$name, $hash| { Resource['Hashfile::Properties'] { $name: * => $hash, } }
  $yaml.each       |$name, $hash| { Resource['Hashfile::Yaml']       { $name: * => $hash, } }
}