Defined Type: icingaweb2::module

Defined in:
manifests/module.pp

Summary

Download, enable and configure Icinga Web 2 modules.

Overview

Note:

If you want to use ‘git` as `install_method`, the CLI `git` command has to be installed. You can manage it yourself as package resource or declare the package name in icingaweb2 class parameter `extra_packages`.

Examples:

$conf_dir        = $icingaweb2::globals::conf_dir
$module_conf_dir = "${conf_dir}/modules/mymodule"

$settings = {
  'section1' => {
    'target'   => "${module_conf_dir}/config1.ini",
    'settings' => {
      'setting1' => 'value1',
      'setting2' => 'value2',
    }
  },
  'section2' => {
    'target'   => "${module_conf_dir}/config2.ini",
    'settings' => {
      'setting3' => 'value3',
      'setting4' => 'value4',
    }
  }
}

Parameters:

  • ensure (Enum['absent', 'present']) (defaults to: 'present')

    Enable or disable module.

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

    Name of the module.

  • module_dir (Stdlib::Absolutepath) (defaults to: "${icingaweb2::globals::default_module_path}/${title}")

    Target directory of the module. Defaults to first item of ‘module_path`.

  • install_method (Enum['git', 'none', 'package']) (defaults to: 'git')

    Install methods are ‘git`, `package` and `none` is supported as installation method. Defaults to `git`

  • git_repository (Optional[String]) (defaults to: undef)

    The git repository. This setting is only valid in combination with the installation method ‘git`.

  • git_revision (String) (defaults to: 'master')

    Tag or branch of the git repository. This setting is only valid in combination with the installation method ‘git`.

  • package_name (Optional[String]) (defaults to: undef)

    Package name of the module. This setting is only valid in combination with the installation method ‘package`.

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

    A hash with the module settings. Multiple configuration files with ini sections can be configured with this hash. The ‘module_name` should be used as target directory for the configuration files.



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'manifests/module.pp', line 52

define icingaweb2::module (
  Enum['absent', 'present']         $ensure         = 'present',
  String                            $module         = $title,
  Stdlib::Absolutepath              $module_dir     = "${icingaweb2::globals::default_module_path}/${title}",
  Enum['git', 'none', 'package']    $install_method = 'git',
  Optional[String]                  $git_repository = undef,
  String                            $git_revision   = 'master',
  Optional[String]                  $package_name   = undef,
  Hash                              $settings       = {},
) {
  require icingaweb2

  $conf_dir   = $icingaweb2::globals::conf_dir
  $state_dir  = $icingaweb2::globals::state_dir
  $conf_user  = $icingaweb2::conf_user
  $conf_group = $icingaweb2::conf_group

  $enable_module = if $ensure == 'present' {
    'link'
  } else {
    'absent'
  }

  file {
    default:
      owner => $conf_user,
      group => $conf_group,
      ;
    "${conf_dir}/enabledModules/${module}":
      ensure => $enable_module,
      target => $module_dir,
      ;
    ["${conf_dir}/modules/${module}", "${state_dir}/${module}"]:
      ensure => directory,
      owner  => 'root',
      mode   => '2770',
      ;
  }

  create_resources('icingaweb2::inisection', $settings)

  case $install_method {
    'none': {}
    'git': {
      vcsrepo { $module_dir:
        ensure   => present,
        provider => 'git',
        source   => $git_repository,
        revision => $git_revision,
      }
    }
    'package': {
      package { $package_name:
        ensure => installed,
      }
    }
    default: {
      fail('The installation method you provided is not supported.')
    }
  }
}