Defined Type: icinga2::object::host

Defined in:
manifests/object/host.pp

Summary

Manage Icinga 2 Host objects.

Overview

Parameters:

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

    Set to present enables the object, absent disables it.

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

    Hostname of the Host object.

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

    Sorted List of templates to include.

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

    A short description of the host (e.g. displayed by external interfaces instead of the name if set).

  • address (Optional[Stdlib::Host]) (defaults to: undef)

    The host’s address v4.

  • address6 (Optional[Stdlib::Host]) (defaults to: undef)

    The host’s address v6.

  • vars (Optional[Icinga2::CustomAttributes]) (defaults to: undef)

    A dictionary containing custom attributes that are specific to this service, a string to do operations on this dictionary or an array for multiple use of custom attributes.

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

    A list of host groups this host belongs to.

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

    The name of the check command.

  • max_check_attempts (Optional[Integer[1]]) (defaults to: undef)

    The number of times a host is re-checked before changing into a hard state.

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

    The name of a time period which determines when this host should be checked.

  • check_timeout (Optional[Icinga2::Interval]) (defaults to: undef)

    Check command timeout in seconds. Overrides the CheckCommand’s timeout attribute.

  • check_interval (Optional[Icinga2::Interval]) (defaults to: undef)

    The check interval (in seconds). This interval is used for checks when the host is in a HARD state.

  • retry_interval (Optional[Icinga2::Interval]) (defaults to: undef)

    The retry interval (in seconds). This interval is used for checks when the host is in a SOFT state.

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

    Whether notifications are enabled.

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

    Whether active checks are enabled.

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

    Whether passive checks are enabled.

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

    Enables event handlers for this host.

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

    Whether flap detection is enabled.

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

    Whether performance data processing is enabled.

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

    The name of an event command that should be executed every time the host’s state changes or the host is in a SOFT state.

  • flapping_threshold_low (Optional[Integer[1]]) (defaults to: undef)

    Flapping lower bound in percent for a host to be considered not flapping.

  • flapping_threshold_high (Optional[Integer[1]]) (defaults to: undef)

    Flapping upper bound in percent for a host to be considered flapping.

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

    The volatile setting enables always HARD state types if NOT-OK state changes occur.

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

    The zone this object is a member of.

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

    The endpoint where commands are executed on.

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

    Notes for the host.

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

    Url for notes for the host (for example, in notification commands).

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

    Url for actions for the host (for example, an external graphing tool).

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

    Icon image for the host. Used by external interfaces only.

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

    Icon image description for the host. Used by external interface only.

  • template (Boolean) (defaults to: false)

    Set to true creates a template instead of an object.

  • 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: 50)

    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`.



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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
# File 'manifests/object/host.pp', line 113

define icinga2::object::host (
  Stdlib::Absolutepath                 $target,
  Enum['absent', 'present']            $ensure                  = present,
  String[1]                            $host_name               = $title,
  Array[String[1]]                     $import                  = [],
  Optional[Stdlib::Host]               $address                 = undef,
  Optional[Stdlib::Host]               $address6                = undef,
  Optional[Icinga2::CustomAttributes]  $vars                    = undef,
  Optional[Array[String[1]]]           $groups                  = undef,
  Optional[String[1]]                  $display_name            = undef,
  Optional[String[1]]                  $check_command           = undef,
  Optional[Integer[1]]                 $max_check_attempts      = undef,
  Optional[String[1]]                  $check_period            = undef,
  Optional[Icinga2::Interval]          $check_timeout           = undef,
  Optional[Icinga2::Interval]          $check_interval          = undef,
  Optional[Icinga2::Interval]          $retry_interval          = undef,
  Optional[Boolean]                    $enable_notifications    = undef,
  Optional[Boolean]                    $enable_active_checks    = undef,
  Optional[Boolean]                    $enable_passive_checks   = undef,
  Optional[Boolean]                    $enable_event_handler    = undef,
  Optional[Boolean]                    $enable_flapping         = undef,
  Optional[Boolean]                    $enable_perfdata         = undef,
  Optional[String[1]]                  $event_command           = undef,
  Optional[Integer[1]]                 $flapping_threshold_low  = undef,
  Optional[Integer[1]]                 $flapping_threshold_high = undef,
  Optional[Boolean]                    $volatile                = undef,
  Optional[String[1]]                  $zone                    = undef,
  Optional[String[1]]                  $command_endpoint        = undef,
  Optional[String[1]]                  $notes                   = undef,
  Optional[String[1]]                  $notes_url               = undef,
  Optional[String[1]]                  $action_url              = undef,
  Optional[String[1]]                  $icon_image              = undef,
  Optional[String[1]]                  $icon_image_alt          = undef,
  Boolean                              $template                = false,
  Variant[String[1], Integer[0]]       $order                   = 50,
  Variant[Array[String[1]], String[1]] $export                  = [],
) {
  require icinga2::globals

  # compose the attributes
  $attrs = {
    'address'                 => $address,
    'address6'                => $address6,
    'groups'                  => $groups,
    'display_name'            => $display_name,
    'check_command'           => $check_command,
    'max_check_attempts'      => $max_check_attempts,
    'check_period'            => $check_period,
    'check_timeout'           => $check_timeout,
    'check_interval'          => $check_interval,
    'retry_interval'          => $retry_interval,
    'enable_notifications'    => $enable_notifications,
    'enable_active_checks'    => $enable_active_checks,
    'enable_passive_checks'   => $enable_passive_checks,
    'enable_event_handler'    => $enable_event_handler,
    'enable_flapping'         => $enable_flapping,
    'enable_perfdata'         => $enable_perfdata,
    'event_command'           => $event_command,
    'flapping_threshold_low'  => $flapping_threshold_low,
    'flapping_threshold_high' => $flapping_threshold_high,
    'volatile'                => $volatile,
    'zone'                    => $zone,
    'command_endpoint'        => $command_endpoint,
    'notes'                   => $notes,
    'notes_url'               => $notes_url,
    'action_url'              => $action_url,
    'icon_image'              => $icon_image,
    'icon_image_alt'          => $icon_image_alt,
    'vars'                    => $vars,
  }

  # create object
  $config = {
    'object_name' => $host_name,
    'object_type' => 'Host',
    'template'    => $template,
    'import'      => $import,
    'attrs'       => delete_undef_values($attrs),
    'attrs_list'  => keys($attrs),
  }

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