Puppet 3 Functions

Defined in:
to_hash_settings: lib/puppet/parser/functions/to_hash_settings.rb (3)
ensure_prefix: lib/puppet/parser/functions/ensure_prefix.rb (3)

Available Functions

Function Details

(rvalue) to_hash_settings

This function converts a {key => value} hash into a nested hash and can add an id to the outer key. The optional id string as second parameter is prepended to the resource name.

Examples:

to_hash_settings({'a' => 1, 'b' => 2})

Would return:

{
  'a' => {'key' => 'a', 'value' => 1},
  'b' => {'key' => 'b', 'value' => 2}
}

and:

to_hash_settings({'a' => 1, 'b' => 2}, 'foo')

Would return:

{
  'foo: a' => {'key' => 'a', 'value' => 1},
  'foo: b' => {'key' => 'b', 'value' => 2}
}

Returns:

  • (rvalue)-

(rvalue) ensure_prefix

This function ensures a prefix for all elements in an array or the keys in a hash.

Examples:

ensure_prefix({'a' => 1, 'b' => 2, 'p.c' => 3}, 'p.')

Will return:

{
  'p.a' => 1,
  'p.b' => 2,
  'p.c' => 3,
}

ensure_prefix(['a', 'p.b', 'c'], 'p.')

Will return:

['p.a', 'p.b', 'p.c']

Returns:

  • (rvalue)-