Defined Type: icinga2::object::dependency

Defined in:
manifests/object/dependency.pp

Summary

Manage Icinga 2 dependency objects.

Overview

Parameters:

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

    Set to present enables the object, absent disables it.

  • dependency_name (String[1]) (defaults to: $title)

    Set the Icinga 2 name of the dependency object.

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

    The parent host.

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

    The parent service. If omitted, this dependency object is treated as host dependency.

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

    The child host.

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

    The child service. If omitted, this dependency object is treated as host dependency.

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

    The redundancy group - puts the dependency into a group of mutually redundant ones.

  • disable_checks (Optional[Boolean]) (defaults to: undef)

    Whether to disable checks when this dependency fails.

  • disable_notifications (Optional[Boolean]) (defaults to: undef)

    Whether to disable notifications when this dependency fails. true.

  • ignore_soft_states (Optional[Boolean]) (defaults to: undef)

    Whether to ignore soft states for the reachability calculation. true.

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

    Time period during which this dependency is enabled.

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

    A list of state filters when this dependency should be OK.

  • apply (Variant[Boolean, String[1]]) (defaults to: false)

    Dispose an apply instead an object if set to ‘true’. Value is taken as statement, i.e. ‘vhost => config in host.vars.vhosts’.

  • prefix (Variant[Boolean, String[1]]) (defaults to: false)

    Set dependency_name as prefix in front of ‘apply for’. Only effects if apply is a string.

  • apply_target (Enum['Host', 'Service']) (defaults to: 'Host')

    An object type on which to target the apply rule. Valid values are ‘Host` and `Service`.

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

    Assign user group members using the group assign rules.

  • ignore (Array[String[1]]) (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[String[1]]) (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[1], Integer[0]]) (defaults to: 70)

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

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

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



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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'manifests/object/dependency.pp', line 77

define icinga2::object::dependency (
  Stdlib::Absolutepath                 $target,
  Enum['absent', 'present']            $ensure                = present,
  String[1]                            $dependency_name       = $title,
  Optional[String[1]]                  $parent_host_name      = undef,
  Optional[String[1]]                  $parent_service_name   = undef,
  Optional[String[1]]                  $child_host_name       = undef,
  Optional[String[1]]                  $child_service_name    = undef,
  Optional[String[1]]                  $redundancy_group      = undef,
  Optional[Boolean]                    $disable_checks        = undef,
  Optional[Boolean]                    $disable_notifications = undef,
  Optional[Boolean]                    $ignore_soft_states    = undef,
  Optional[String[1]]                  $period                = undef,
  Optional[Array]                      $states                = undef,
  Variant[Boolean, String[1]]          $apply                 = false,
  Variant[Boolean, String[1]]          $prefix                = false,
  Enum['Host', 'Service']              $apply_target          = 'Host',
  Array[String[1]]                     $assign                = [],
  Array[String[1]]                     $ignore                = [],
  Array[String[1]]                     $import                = [],
  Boolean                              $template              = false,
  Variant[String[1], Integer[0]]       $order                 = 70,
  Variant[Array[String[1]], String[1]] $export                = [],
) {
  require icinga2::globals

  # compose attributes
  $attrs = {
    'parent_host_name'      => $parent_host_name,
    'parent_service_name'   => $parent_service_name,
    'child_host_name'       => $child_host_name,
    'child_service_name'    => $child_service_name,
    'redundancy_group'      => $redundancy_group,
    'disable_checks'        => $disable_checks,
    'disable_notifications' => $disable_notifications,
    'ignore_soft_states'    => $ignore_soft_states,
    'period'                => $period,
    'states'                => $states,
  }

  # create object
  $config = {
    'object_name'  => $dependency_name,
    'object_type'  => 'Dependency',
    'import'       => $import,
    'template'     => $template,
    'attrs'        => delete_undef_values($attrs),
    'attrs_list'   => keys($attrs),
    'apply'        => $apply,
    'prefix'       => $prefix,
    'apply_target' => $apply_target,
    'assign'       => $assign,
    'ignore'       => $ignore,
  }

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