Defined Type: icingaweb2::inisection

Defined in:
manifests/inisection.pp

Summary

Manage settings in INI configuration files.

Overview

Examples:

Create the configuration file and set two settings for the section ‘global`:

include icingawebeb2

icingaweb2::inisection { '/path/to/config.ini':
  settings => {
    'global' => {
      'setting1' => 'value',
      'setting2' => 'value',
    },
  },
}

Parameters:

  • target (Stdlib::Absolutepath)

    Absolute path to the configuration file.

  • section_name (String) (defaults to: $title)

    Name of the target section. Settings are set under [$section_name]

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

    A hash of settings and their settings. Single settings may be set to absent.

  • order (Variant[String, Integer]) (defaults to: '01')

    Ordering of the INI section within a file. Defaults to ‘01`

  • replace (Boolean) (defaults to: true)

    Specifies whether to overwrite the destination file if it already exists.



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'manifests/inisection.pp', line 31

define icingaweb2::inisection (
  Stdlib::Absolutepath      $target,
  String                    $section_name  = $title,
  Hash                      $settings      = {},
  Variant[String, Integer]  $order         = '01',
  Boolean                   $replace       = true,
) {
  $conf_user      = $icingaweb2::conf_user
  $conf_group     = $icingaweb2::conf_group

  if !defined(Concat[$target]) {
    concat { $target:
      ensure  => present,
      warn    => false,
      replace => $replace,
      owner   => $conf_user,
      group   => $conf_group,
      mode    => '0640',
    }
  }

  concat::fragment { "${title}-${section_name}-${order}":
    target  => $target,
    content => template('icingaweb2/inisection.erb'),
    order   => $order,
  }
}