Puppet Function: choria::hash2config

Defined in:
functions/hash2config.pp
Function type:
Puppet Language

Overview

choria::hash2config(Hash $confighash)String

Generates configuration files for mcollective. Keys are sorted alphabetically: key = value

Parameters:

  • confighash (Hash)

Returns:

  • (String)


3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'functions/hash2config.pp', line 3

function choria::hash2config(Hash $confighash) >> String {
  $result = $confighash.keys.sort.map |$key| {
    $val = $confighash[$key]

    if $val =~ Array {
      $val.each |$item| {
        unless $item =~ Integer or $item =~ Float or $item =~ String {
          fail("Array values are only supported for Integer, Float or String data types")
        }
      }

      sprintf("%s = %s", $key, $val.join(", "))
    } else {
      sprintf("%s = %s", $key, $val)
    }
  }
  ($result << []).join("\n")
}