Puppet Function: unbound::print_config

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

Summary

Print a configuration value if it is defined and the version is supported

Overview

unbound::print_config(String[1] $name, Optional[Variant[Boolean, Integer, String, Array[String, 1]]] $value = undef, Optional[String[1]] $version = undef)String

Parameters:

  • name (String[1])

    the config item name

  • value (Optional[Variant[Boolean, Integer, String, Array[String, 1]]]) (defaults to: undef)

    the config item value

  • version (Optional[String[1]]) (defaults to: undef)

    the version when the config item was introduced

Returns:

  • (String)

    the config item as a string or an empty string if the version is not supported



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

function unbound::print_config (
  String[1]                                                     $name,
  Optional[Variant[Boolean, Integer, String, Array[String, 1]]] $value   = undef,
  Optional[String[1]]                                           $version = undef,
) >> String {
  $unbound_version = $facts['unbound_version'].lest || { '0.a' }
  if ($value =~ Undef or ($version =~ NotUndef and versioncmp($unbound_version, $version) < 0)) {
    return ''
  }
  $value ? {
    String  => "  ${name}: \"${value}\"",
    Integer => "  ${name}: ${value}",
    Boolean => "  ${name}: ${value.bool2str('yes', 'no')}",
    Array   => $value.map |$v| { "  ${name}: \"${v}\"" }.join("\n"),
  }
}