Skip to content
This repository has been archived by the owner on Nov 6, 2024. It is now read-only.

Commit

Permalink
Merge pull request #260 from vkhatri/fixes
Browse files Browse the repository at this point in the history
bug fix
  • Loading branch information
vkhatri authored Jan 22, 2017
2 parents b5e75d0 + 44410b5 commit be62199
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 62 deletions.
34 changes: 13 additions & 21 deletions .kitchen.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,36 @@
---
<%
db_host = ENV['KITCHEN_DB_HOST'] || 'localhost'
chef_omnibus_url = ENV['KITCHEN_CHEF_OMNIBUS_URL'] || nil
%>
driver:
name: vagrant

provisioner:
name: chef_zero
<% if chef_omnibus_url %>
chef_omnibus_url: '<%= chef_omnibus_url %>'
<% end %>

platforms:
- name: ubuntu-14.04
- name: centos-6.8
- name: centos-7.2
- name: ubuntu-14.04
- name: ubuntu-16.04
- name: debian-7
- name: debian-8

suites:
- name: server
require_chef_omnibus: 12.14.60
run_list:
- recipe[icinga2::server]
- recipe[icinga2-test::default]
attributes:
icinga2:
version: '2.5.4-1'

- name: client
run_list:
- recipe[icinga2::client]
attributes:
icinga2:
version: '2.5.4-1'

- name: web2-package
require_chef_omnibus: 12.14.60
driver:
network:
- ["forwarded_port", {guest: 80, host: 8080, auto_correct: true}]
Expand All @@ -38,18 +40,14 @@ suites:
- recipe[icinga2-test::default]
attributes:
icinga2:
version: '2.5.4-1'
web2:
enable: true
install_method: package
version: 2.3.4
ido:
install_mysql_client: true
db_host: 192.168.1.152
db_host: <%= db_host %>
load_schema: true
db_password: rooT-123
- name: web2-source
require_chef_omnibus: 12.14.60
driver:
network:
- ["forwarded_port", {guest: 80, host: 8080, auto_correct: true}]
Expand All @@ -59,18 +57,14 @@ suites:
- recipe[icinga2-test::default]
attributes:
icinga2:
version: '2.5.4-1'
web2:
enable: true
install_method: source
version: 2.3.4
ido:
install_mysql_client: true
db_host: 192.168.1.152
db_host: <%= db_host %>
load_schema: true
db_password: rooT-123
- name: classicui
require_chef_omnibus: 12.14.60
driver:
network:
- ["forwarded_port", {guest: 80, host: 8080, auto_correct: true}]
Expand All @@ -80,7 +74,5 @@ suites:
- recipe[icinga2-test::default]
attributes:
icinga2:
version: '2.5.4-1'
classic_ui:
version: '2.5.4-1'
enable: true
59 changes: 35 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ icinga2 Cookbook

[![Cookbook](http://img.shields.io/badge/cookbook-v2.9.1-green.svg)](https://github.com/icinga/chef-icinga2) [![Build Status](https://travis-ci.org/Icinga/chef-icinga2.svg?branch=master)](https://travis-ci.org/Icinga/chef-icinga2)[![Build Status](https://jenkins-01.eastus.cloudapp.azure.com/job/icinga2-cookbook/badge/icon)](https://jenkins-01.eastus.cloudapp.azure.com/job/icinga2-cookbook/)

![Icinga Logo](https://www.icinga.com/wp-content/uploads/2014/06/icinga_logo.png)

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


Expand Down Expand Up @@ -197,15 +199,24 @@ use `Array` attribute `default['icinga2']['user_defined_objects_dir']` instead.

## Icinga2 Server Setup Recipes

### Disable 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']`.


### How to Install and Configure Icinga2 Server without UI

- add recipe `icinga2::server` to your run_list


### How to Install and Configure Icinga2 Server with ClassicUI

- set node['icinga2']['classic_ui']['enable'] = true
- add recipe `icinga2::server` to your run_list


### How to Install and Configure Icinga2 Server with ClassicUI and PNP

- set node['icinga2']['classic_ui']['enable'] = true
Expand Down Expand Up @@ -1981,7 +1992,7 @@ Above LWRP resource will apply `Dependency` to all `Host` objects for provided `

## Cookbook Core Attributes

* `default['icinga2']['version']` (default: `2.5.4-1`): icinga2 version
* `default['icinga2']['version']` (default: `2.6.0-X, calculated`): icinga2 version

* `default['icinga2']['conf_dir']` (default: `/etc/icinga2`): icinga2 configuration location

Expand Down Expand Up @@ -2090,23 +2101,23 @@ Above LWRP resource will apply `Dependency` to all `Host` objects for provided `

## Cookbook Icinga2 IDO Attributes

* `default[:icinga2]['ido']['type']` (default: `mysql`): icinga2 ido type, valid are `mysql pgsql`
* `default['icinga2']['ido']['type']` (default: `mysql`): icinga2 ido type, valid are `mysql pgsql`

* `default[:icinga2]['ido']['load_schema']` (default: `false`): whether to load db schema
* `default['icinga2']['ido']['load_schema']` (default: `false`): whether to load db schema

* `default[:icinga2]['ido']['install_mysql_client']` (default: `false`): install mysql client using mysql official repository
* `default['icinga2']['ido']['install_mysql_client']` (default: `false`): install mysql client using mysql official repository

* `default[:icinga2]['ido']['db_host']` (default: `localhost`): Icinga2 ido db host
* `default['icinga2']['ido']['db_host']` (default: `localhost`): Icinga2 ido db host

* `default[:icinga2]['ido']['db_port']` (default: `3306`): Icinga2 ido db port
* `default['icinga2']['ido']['db_port']` (default: `3306`): Icinga2 ido db port

* `default[:icinga2]['ido']['db_name']` (default: `icinga`): Icinga2 ido db name
* `default['icinga2']['ido']['db_name']` (default: `icinga`): Icinga2 ido db name

* `default[:icinga2]['ido']['db_user']` (default: `icinga`): Icinga2 ido db user
* `default['icinga2']['ido']['db_user']` (default: `icinga`): Icinga2 ido db user

* `default[:icinga2]['ido']['db_password']` (default: `icinga`): Icinga2 ido db password
* `default['icinga2']['ido']['db_password']` (default: `icinga`): Icinga2 ido db password

* `default[:icinga2]['ido']['mysql_home']` (default: `/etc/mysql`): sets value for environment variable `MYSQL_HOME` for schema load
* `default['icinga2']['ido']['mysql_home']` (default: `/etc/mysql`): sets value for environment variable `MYSQL_HOME` for schema load

* `default['icinga2']['ido']['mysql_version']` (default: `false`): install mysql client if set true

Expand Down Expand Up @@ -2143,32 +2154,32 @@ Above LWRP resource will apply `Dependency` to all `Host` objects for provided `

## Cookbook Icingaweb2 Attributes

* `default[:icinga2][:web2][:enable]` (default: `false`): whether to setup icingaweb2
* `default['icinga2']['web2']['enable']` (default: `false`): whether to setup icingaweb2

* `default[:icinga2][:web2][:install_method]` (default: `package`): icingaweb2 install method, options: package, source
* `default['icinga2']['web2']['install_method']` (default: `package`): icingaweb2 install method, options: package, source

* `default[:icinga2][:web2][:source_url]` (default: `git://git.icinga.org/icingaweb2.git`):
* `default['icinga2']['web2']['source_url']` (default: `git://git.icinga.org/icingaweb2.git`):

* `default[:icinga2][:web2][:version]` (default: `2.3.4`): icingaweb2 package version / git branch / git tag etc.
* `default['icinga2']['web2']['version']['icingaweb2']` (default: `2.4.1-1`): icingaweb2 version

* `default[:icinga2][:web2][:release]` (default: `1`): icingaweb2 package release
* `default['icinga2']['web2']['version']['icingacli']` (default: `2.4.1-1`): icingacli version

* `default[:icinga2][:web2][:web_root]` (default: `/usr/share/icingaweb2`): icingaweb2 web root location
* `default['icinga2']['web2']['web_root']` (default: `/usr/share/icingaweb2`): icingaweb2 web root location

* `default[:icinga2][:web2][:web_uri]` (default: `/icingaweb2`): icingweb2 web uri
* `default['icinga2']['web2']['web_uri']` (default: `/icingaweb2`): icingweb2 web uri

* `default[:icinga2][:web2][:conf_dir]` (default: `/etc/icingaweb2`): icingaweb2 config directory
* `default['icinga2']['web2']['conf_dir']` (default: `/etc/icingaweb2`): icingaweb2 config directory

* `default[:icinga2][:web2][:log_dir]` (default: `/var/log/icingaweb2`): icingaweb2 log directory
* `default['icinga2']['web2']['log_dir']` (default: `/var/log/icingaweb2`): icingaweb2 log directory


## Cookbook Ulimit Attributes

* `default[:icinga2][:limits][:memlock]` (default: `unlimited`): Icinga2 service user memory limit
* `default['icinga2']['limits']['memlock']` (default: `unlimited`): Icinga2 service user memory limit

* `default[:icinga2][:limits][:nofile]` (default: `48000`): Icinga2 service user file limit
* `default['icinga2']['limits']['nofile']` (default: `48000`): Icinga2 service user file limit

* `default[:icinga2][:limits][:nproc]` (default: `unlimited`): Icinga2 service user process limit
* `default['icinga2']['limits']['nproc']` (default: `unlimited`): Icinga2 service user process limit


## Cookbook Repository Attributes
Expand Down Expand Up @@ -2208,9 +2219,9 @@ Above LWRP resource will apply `Dependency` to all `Host` objects for provided `

* `default['icinga2']['classic_ui']['enable']` (default: `false`): setup icinga2 classic-ui if set true

* `default['icinga2']['classic_ui']['version']` (default: `2.5.4-1`): icinga2 classic-ui package version
* `default['icinga2']['classic_ui']['version']` (default: `2.6.0-1`): icinga2 classic-ui package version

* `default['icinga2']['classic_ui']['gui_version']` (default: `1.13.3-0`): icinga2 gui package version
* `default['icinga2']['classic_ui']['gui_version']` (default: `1.14.0-0`): icinga2 gui package version

* `default['icinga2']['classic_ui']['web_root']` (default: `/usr/share/icinga`): icinga2 web doc root directory location

Expand Down
5 changes: 4 additions & 1 deletion attributes/default.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# frozen_string_literal: true
# http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/getting-started#getting-started

default['icinga2']['version'] = '2.5.4-1'
default['icinga2']['version'] = value_for_platform(
%w(centos redhat fedora amazon) => { 'default' => '2.6.0-1' },
%w(debian ubuntu) => { 'default' => '2.6.0-2' }
)

default['icinga2']['enable_env_pki'] = false
default['icinga2']['ignore_version'] = false
Expand Down
7 changes: 5 additions & 2 deletions attributes/server_classic_ui.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@
%w(debian ubuntu) => { 'default' => 'icinga2-classicui' }
)

default['icinga2']['classic_ui']['version'] = '2.5.4-1'
default['icinga2']['classic_ui']['version'] = value_for_platform(
%w(centos redhat fedora amazon) => { 'default' => '2.6.0-1' },
%w(debian ubuntu) => { 'default' => '2.6.0-2' }
)

default['icinga2']['classic_ui']['gui_version'] = '1.13.3-0'
default['icinga2']['classic_ui']['gui_version'] = '1.14.0-0'
default['icinga2']['classic_ui']['web_root'] = value_for_platform(
%w(centos redhat fedora amazon) => { 'default' => '/usr/share/icinga' },
%w(debian ubuntu) => { 'default' => '/usr/share/icinga2/classicui' }
Expand Down
7 changes: 2 additions & 5 deletions attributes/server_web2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@
default['icinga2']['web2']['enable'] = false
default['icinga2']['web2']['install_method'] = 'package' # source
default['icinga2']['web2']['source_url'] = 'https://github.com/Icinga/icingaweb2.git'
default['icinga2']['web2']['version'] = '2.3.4'
default['icinga2']['web2']['release'] = value_for_platform(
%w(centos redhat fedora amazon) => { 'default' => '1' }
)
default['icinga2']['web2']['version']['icingaweb2'] = '2.4.1-1'
default['icinga2']['web2']['version']['icingacli'] = '2.4.1-1'
default['icinga2']['web2']['web_root'] = '/usr/share/icingaweb2'
default['icinga2']['web2']['web_uri'] = '/icingaweb2'
default['icinga2']['web2']['conf_dir'] = '/etc/icingaweb2'
default['icinga2']['web2']['log_dir'] = '/var/log/icingaweb2'
default['icinga2']['web2']['release'] = '1'
1 change: 1 addition & 0 deletions recipes/server_apache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#

node.default['apache']['servertokens'] = 'Minimal'
node.default['apache']['mpm'] = 'prefork'

node['icinga2']['apache_modules'].each { |mod| include_recipe "apache2::#{mod}" }

Expand Down
11 changes: 6 additions & 5 deletions recipes/server_web2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
# limitations under the License.
#

web2_version = node['icinga2']['web2']['install_method'] == 'source' ? 'v' + node['icinga2']['web2']['version'] : node['icinga2']['web2']['version'] + '-' + node['icinga2']['web2']['release'] + node['icinga2']['icinga2_version_suffix'].to_s
cli_version = node['icinga2']['web2']['version'] + '-' + node['icinga2']['web2']['release'] + node['icinga2']['icinga2_version_suffix']
cli_package_version = node['icinga2']['web2']['version']['icingacli'] + node['icinga2']['icinga2_version_suffix']
web2_package_version = node['icinga2']['web2']['version']['icingaweb2'] + node['icinga2']['icinga2_version_suffix']
web2_source_version = 'v' + node['icinga2']['web2']['version']['icingaweb2'].split('-')[0]

if node.attribute?('time') && node['time'].attribute?('timezone')
timezone = node['time']['timezone']
Expand Down Expand Up @@ -88,7 +89,7 @@

git node['icinga2']['web2']['web_root'] do
repository node['icinga2']['web2']['source_url']
revision web2_version
revision web2_source_version
user node[node['icinga2']['web_engine']]['user']
group node[node['icinga2']['web_engine']]['group']
only_if { node['icinga2']['web2']['install_method'] == 'source' }
Expand All @@ -97,12 +98,12 @@
else
package 'icingaweb2' do
# skip ubuntu version for now
version web2_version unless node['icinga2']['ignore_version'] || !(node['platform_family'] == 'rhel')
version web2_package_version unless node['icinga2']['ignore_version'] || !(node['platform_family'] == 'rhel')
notifies :restart, 'service[icinga2]', :delayed
end

package 'icingacli' do
version cli_version unless node['icinga2']['ignore_version']
version cli_package_version unless node['icinga2']['ignore_version']
notifies :restart, 'service[icinga2]', :delayed
only_if { node['platform_family'] == 'rhel' }
end
Expand Down
8 changes: 4 additions & 4 deletions spec/unit/recipes/server_classic_ui_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
let(:chef_run) do
ChefSpec::SoloRunner.new(platform: 'centos', version: '6.4') do |node|
node.automatic['platform_family'] = 'rhel'
node.set['icinga2']['classic_ui']['enable'] = true
node.set['icinga2']['ignore_version'] = true
node.override['icinga2']['classic_ui']['enable'] = true
node.override['icinga2']['ignore_version'] = true
end.converge(described_recipe)
end

Expand Down Expand Up @@ -59,8 +59,8 @@
let(:chef_run) do
ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '12.04') do |node|
node.automatic['platform_family'] = 'debian'
node.set['icinga2']['classic_ui']['enable'] = true
node.set['icinga2']['ignore_version'] = true
node.override['icinga2']['classic_ui']['enable'] = true
node.override['icinga2']['ignore_version'] = true
end.converge(described_recipe)
end

Expand Down

0 comments on commit be62199

Please sign in to comment.