Icinga / chef-icinga2

Icinga 2 Chef Cookbook
https://supermarket.chef.io/cookbooks/icinga2
Apache License 2.0
41 stars 55 forks source link
chef cookbooks icinga2

icinga2 Cookbook

Cookbook Build Status Build Status

Icinga Logo

This is a Chef cookbook to manage Icinga2 using Chef LWRP.

For Production environment, always prefer the most recent release.

Repository

https://github.com/Icinga/chef-icinga2

Chef Supermarket

https://supermarket.chef.io/cookbooks/icinga2

Issue Tracking

For issue reporting or any discussion regarding this cookbook, open an issue.

Supported Platform

Chef Version

Contributing

See CONTRIBUTING.md

Major Changes

v4.0.0

v2.9.1

v2.8.0

v2.7.1

Existing host_ENVIRONMENT.conf configuration files needs to be purged manually to allow new file name configuration files.

New File Format:
With Zone: "host_#{environment}_#{zone}_#{resource_name}.conf"
Without Zone: "host_#{environment}_#{resource_name}.conf"

Old File Format:
With Zone: "host_#{environment}_#{zone}.conf"
Without Zone: "host_#{environment}.conf"

v2.6.9

v2.0.1

v0.10.1

v0.7.0

file name:

file name without zone: `host_#{environment}_#{resource_name}.conf`

file name with zone: `host_#{environment}_#{zone}_#{resource_name}.conf`

Note: Cookbook version prior to v0.7.0 users must delete configuration file host_#{environment}.conf manually if zone attribute is defined.

Note: Cookbook version prior to v2.7.1 users must delete configuration files host_#{environment}.conf / host_#{environment}_#{zone}.conf manually.

Cookbook Dependencies

Recipes

Icinga2 Default Configuration Directory

If you are using this cookbook to manage icinga2 configuration, set default['icinga2']['disable_conf_d'] to true.

Cookbook generated configuration files using LWRP are created under directory default['icinga2']['objects_dir'].

default['icinga2']['disable_conf_d'] default value is set to true.

Icinga2 Cookbooks and Recipes

How to Install and Configure Icinga2 Server?

Add recipe icinga2::default to run_list.

How to Setup Icinga2 YUM/APT Repository?

Cookbook icinga2repo::default is used to setup icinga2 yum/apt repository. For more information, see cookbook icinga2repo.

How to Install and Configure Icinga2 Client?

Add recipe icinga2client::default to run_list. For more information, see cookbook icinga2client.

How to Install and Configure Icingaweb2?

Add recipe icingaweb2::default to run_list. For more information, see cookbook icingaweb2.

Icinga2 Cluster Deployment

Icinga2 Distributed / HA cluster setup examples will be added soon.

Icinga2 Monitor a Chef Environment Nodes

This cookbook does not only provide management of Icinga2 server & objects, it also provides automation around Chef environment.

Using LWRP environment a whole environment nodes can be added to Host objects with environment wide Host object parameters.

There are certain functionalities added to LWRP environment, like:

Simply create a LWRP resource for a chef environment, to start monitoring all nodes in that environment. More details can be found in examples.

Icinga2 Monitor an User Defined Chef Environment Nodes/HostGroups

Last section explains the benefits of using LWRP environment using in built library search function to determine chef_environment nodes / icinga2 Host and auto create icinga2 HostGroup.

This section explains how a user can provide a custom inventory list of nodes, host groups etc.

To find all the valid chef nodes for a chef environment, this cookbook uses default library icinga2::search. There are lots of custom & cloud specific attributes embedded in it which may or may not work for every scenarios.

To overcome and make it less enforcing, LWRP environment has a Hash attribute env_resources which can be used by an user from a wrapper cookbook recipe to pass chef environment nodes & hostgroups & endpoints & zones. If this attribute is set, cookbook will not use default library to search chef_environment nodes and will create Host objects for user defined values.

env_resources Hash attributes has below valid key names:

e.g.

icinga2_environment 'UserDefinedEnvironment' do
  import node['icinga2']['object']['host']['import']
  environment 'production'
  check_interval '1m'
  retry_interval '10s'
  max_check_attempts 3
  action_url '/pnp4nagios/graph?host=$HOSTNAME$&srv=_HOST_'
  env_resources :nodes => {:fqdn => {attrs}, :fqdn => {attrs}}
end

For more details about nodes attributes, check LWRP environment object template.

Like env_resources, user can also define custom template for LWRP environment using attribute cookbook and template.

Icinga2 Global Host Custom Vars

environment LWRP Host Vars

LWRP environment resources sets Host custom vars for each node via node Hash attribute - node['icinga2']['client']['custom_vars']. All defined vars will be added to Host object.

host LWRP Host Vars

When using icinga2_host LWRP, node custom vars will not be added automatically. There will be no search performed as the Host object could be different than a chef Node.

To add Host custom vars, use Hash attribute custom_vars.

A resource attribute will be added to icinga2_host LWRP to perform a search to fetch custom vars defined for a node, so that manual addition is not required.

Icinga2 Node Attributes as Host Custom Vars

environment resource attribute add_node_vars can add a node attribute to Host custom vars.

e.g. to add a custom var hardware with value of node attribute node['dmi']['system']['manufacturer']

icinga2_environment 'environment' do
  add_node_vars 'hardware' => %w(dmi system manufacturer)
end

It will add a custom var vars.hardware to environment Host objects.

Icinga2 User Defined Objects / Configuration

Attribute node['icinga2']['user_defined_objects_dir'] manages user defined configuration directories location.

Directories will be created under /etc/icinga2/ and also included in icinga2.conf.

LWRP

See LWRP.md for icinga2 resources.

Cookbook Advanced Attributes

Cookbook Core Attributes

Cookbook Icinga2 Constants Attributes

Cookbook Icinga2 Host Object default Attributes

Cookbook Ulimit Attributes

Copyright & License

Authors:: Check AUTHORS file

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.