Defined Type: hashfile::json

Defined in:
manifests/json.pp

Summary

Defined type provides an implementation of the hash2json function, creating a JSON file from the input hash

Overview

Examples:

hashfile::json { 'namevar':
  file => {
    ensure => file,
    owner  => 'root',
    group  => 'root',
    mode   => '0644',
  }
  data => {
    section1 => {
      key1   => 'value1',
    }
  }
}

Parameters:

  • file (Hash)

    Properties of the target file resource. Accepts and requires the same parameters of a puppet “file”

  • data (Hash)

    Hash representation of the JSON file.



22
23
24
25
26
27
28
29
# File 'manifests/json.pp', line 22

define hashfile::json (
  Hash $file,
  Hash $data,
) {
  File {$name:
    * => merge($file, content => to_json_pretty($data)),
  }
}