Defined Type: icinga2::object::servicegroup

Defined in:
manifests/object/servicegroup.pp

Summary

Manage Icinga 2 servicegroup objects.

Overview

Parameters:

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

    Set to present enables the object, absent disables it.

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

    Set the Icinga 2 name of the servicegroup object.

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

    A short description of the service group.

  • groups (Optional[Array]) (defaults to: undef)

    An array of nested group names.

  • assign (Array) (defaults to: [])

    Assign user group members using the group assign rules.

  • ignore (Array) (defaults to: [])

    Exclude users using the group ignore rules.

  • template (Boolean) (defaults to: false)

    Set to true creates a template instead of an object.

  • import (Array) (defaults to: [])

    Sorted List of templates to include.

  • target (Stdlib::Absolutepath)

    Destination config file to store in this object. File will be declared the first time.

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

    String or integer to set the position in the target file, sorted alpha numeric.

  • export (Variant[Array[String], String]) (defaults to: [])

    Export object to destination, collected by class ‘icinga2::query_objects`.



38
39
40
41
42
43
44
45
46
47
48
49
50
51
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
# File 'manifests/object/servicegroup.pp', line 38

define icinga2::object::servicegroup (
  Stdlib::Absolutepath           $target,
  Enum['absent', 'present']      $ensure            = present,
  String                         $servicegroup_name = $title,
  Optional[String]               $display_name      = undef,
  Optional[Array]                $groups            = undef,
  Array                          $assign            = [],
  Array                          $ignore            = [],
  Boolean                        $template          = false,
  Array                          $import            = [],
  Variant[String, Integer]       $order             = 65,
  Variant[Array[String], String] $export            = [],
) {
  require icinga2::globals

  # compose attributes
  $attrs = {
    'display_name'  => $display_name,
    'groups'        => $groups,
  }

  # create object
  $config = {
    'object_name' => $servicegroup_name,
    'object_type' => 'ServiceGroup',
    'import'      => $import,
    'template'    => $template,
    'attrs'       => delete_undef_values($attrs),
    'attrs_list'  => keys($attrs),
    'assign'      => $assign,
    'ignore'      => $ignore,
  }

  unless empty($export) {
    @@icinga2::config::fragment { "icinga2::object::ServiceGroup::${title}":
      tag     => prefix(any2array($export), 'icinga2::instance::'),
      content => epp('icinga2/object.conf.epp', $config),
      target  => $target,
      order   => $order,
    }
  } else {
    icinga2::object { "icinga2::object::ServiceGroup::${title}":
      ensure => $ensure,
      target => $target,
      order  => $order,
      *      => $config,
    }
  }
}