From 5a6995f67fa6de92faf7ac6aa1e0e3c8d4270a2d Mon Sep 17 00:00:00 2001 From: Alexander Klimov Date: Fri, 22 Aug 2014 13:37:27 +0200 Subject: [PATCH] Outsource `icinga2' stuff, `icinga2-mysql' stuff and `icinga2::feature' into modules refs #6842 --- .../modules/icinga2-mysql/manifests/init.pp | 37 +++++++++ .../modules/icinga2/manifests/feature.pp | 9 +++ .../modules/icinga2/manifests/init.pp | 36 +++++++++ .../modules/profile/manifests/icinga2.pp | 80 +------------------ 4 files changed, 83 insertions(+), 79 deletions(-) create mode 100644 .vagrant-puppet/modules/icinga2-mysql/manifests/init.pp create mode 100644 .vagrant-puppet/modules/icinga2/manifests/feature.pp create mode 100644 .vagrant-puppet/modules/icinga2/manifests/init.pp diff --git a/.vagrant-puppet/modules/icinga2-mysql/manifests/init.pp b/.vagrant-puppet/modules/icinga2-mysql/manifests/init.pp new file mode 100644 index 000000000..09dcad820 --- /dev/null +++ b/.vagrant-puppet/modules/icinga2-mysql/manifests/init.pp @@ -0,0 +1,37 @@ +class icinga2-mysql { + include icinga2 + + mysql::database::populate { 'icinga2': + username => 'icinga2', + password => 'icinga2', + privileges => 'SELECT,INSERT,UPDATE,DELETE', + schemafile => '/usr/share/icinga2-ido-mysql/schema/mysql.sql', + requirement => Package['icinga2-ido-mysql'], + } + + icinga2::feature { 'ido-mysql': + require => Exec['populate-icinga2-mysql-db'], + } + + package { 'icinga2-ido-mysql': + ensure => latest, + require => Yumrepo['icinga2-repo'], + alias => 'icinga2-ido-mysql' + } + + file { '/etc/icinga2/features-available/ido-mysql.conf': + source => 'puppet:////vagrant/.vagrant-puppet/files/etc/icinga2/features-available/ido-mysql.conf', + owner => 'icinga', + group => 'icinga', + require => Package['icinga2'], + notify => Service['icinga2'], + } + + file { '/etc/icinga2/features-enabled/ido-mysql.conf': + ensure => 'link', + target => '/etc/icinga2/features-available/ido-mysql.conf', + owner => 'root', + group => 'root', + require => Package['icinga2-ido-mysql'], + } +} diff --git a/.vagrant-puppet/modules/icinga2/manifests/feature.pp b/.vagrant-puppet/modules/icinga2/manifests/feature.pp new file mode 100644 index 000000000..0f28771e7 --- /dev/null +++ b/.vagrant-puppet/modules/icinga2/manifests/feature.pp @@ -0,0 +1,9 @@ +define icinga2::feature ($feature = $title) { + exec { "icinga2-feature-${feature}": + path => '/bin:/usr/bin:/sbin:/usr/sbin', + unless => "readlink /etc/icinga2/features-enabled/${feature}.conf", + command => "icinga2-enable-feature ${feature}", + require => [ Package['icinga2'] ], + notify => Service['icinga2'] + } +} diff --git a/.vagrant-puppet/modules/icinga2/manifests/init.pp b/.vagrant-puppet/modules/icinga2/manifests/init.pp new file mode 100644 index 000000000..4f86ccdb2 --- /dev/null +++ b/.vagrant-puppet/modules/icinga2/manifests/init.pp @@ -0,0 +1,36 @@ +class icinga2 { + service { 'icinga2': + ensure => running, + require => [ + Package['icinga2'], + File['/etc/icinga2/features-enabled/ido-mysql.conf'], + File['/etc/icinga2/conf.d/test-config.conf'], + File['/etc/icinga2/conf.d/commands.conf'] + ] + } + + package { 'icinga2': + ensure => latest, + require => Yumrepo['icinga2-repo'], + alias => 'icinga2' + } + + package { 'icinga2-bin': + ensure => latest, + require => [ Yumrepo['icinga2-repo'], Package['icinga2'] ], + alias => 'icinga2-bin' + } + + package { 'icinga2-doc': + ensure => latest, + require => Yumrepo['icinga2-repo'], + alias => 'icinga2-doc' + } + + package { 'icinga2-classicui-config': + ensure => latest, + before => Package["icinga-gui"], + require => [ Yumrepo['icinga2-repo'], Package['icinga2'] ], + notify => Service['apache'], + } +} diff --git a/.vagrant-puppet/modules/profile/manifests/icinga2.pp b/.vagrant-puppet/modules/profile/manifests/icinga2.pp index a337f47e4..99c269607 100644 --- a/.vagrant-puppet/modules/profile/manifests/icinga2.pp +++ b/.vagrant-puppet/modules/profile/manifests/icinga2.pp @@ -1,88 +1,10 @@ class profile::icinga2 ($icinga2Version) { - mysql::database::populate { 'icinga2': - username => 'icinga2', - password => 'icinga2', - privileges => 'SELECT,INSERT,UPDATE,DELETE', - schemafile => '/usr/share/icinga2-ido-mysql/schema/mysql.sql', - requirement => Package['icinga2-ido-mysql'], - } - - define icinga2::feature ($feature = $title) { - exec { "icinga2-feature-${feature}": - path => '/bin:/usr/bin:/sbin:/usr/sbin', - unless => "readlink /etc/icinga2/features-enabled/${feature}.conf", - command => "icinga2-enable-feature ${feature}", - require => [ Package['icinga2'] ], - notify => Service['icinga2'] - } - } + include icinga2-mysql icinga2::feature { [ 'statusdata', 'command', 'compatlog' ]: require => Package['icinga2-classicui-config'], } - icinga2::feature { 'ido-mysql': - require => Exec['populate-icinga2-mysql-db'], - } - - service { 'icinga2': - ensure => running, - require => [ - Package['icinga2'], - File['/etc/icinga2/features-enabled/ido-mysql.conf'], - File['/etc/icinga2/conf.d/test-config.conf'], - File['/etc/icinga2/conf.d/commands.conf'] - ] - } - - package { 'icinga2': - ensure => latest, - require => Yumrepo['icinga2-repo'], - alias => 'icinga2' - } - - package { 'icinga2-bin': - ensure => latest, - require => [ Yumrepo['icinga2-repo'], Package['icinga2'] ], - alias => 'icinga2-bin' - } - - package { 'icinga2-doc': - ensure => latest, - require => Yumrepo['icinga2-repo'], - alias => 'icinga2-doc' - } - - package { 'icinga2-classicui-config': - ensure => latest, - before => Package["icinga-gui"], - require => [ Yumrepo['icinga2-repo'], Package['icinga2'] ], - notify => Service['apache'], - } - - package { 'icinga2-ido-mysql': - ensure => latest, - require => Yumrepo['icinga2-repo'], - alias => 'icinga2-ido-mysql' - } - - - file { '/etc/icinga2/features-available/ido-mysql.conf': - source => 'puppet:////vagrant/.vagrant-puppet/files/etc/icinga2/features-available/ido-mysql.conf', - owner => 'icinga', - group => 'icinga', - require => Package['icinga2'], - notify => Service['icinga2'], - } - - file { '/etc/icinga2/features-enabled/ido-mysql.conf': - ensure => 'link', - target => '/etc/icinga2/features-available/ido-mysql.conf', - owner => 'root', - group => 'root', - require => Package['icinga2-ido-mysql'], - } - file { '/etc/icinga2/conf.d/test-config.conf': source => 'puppet:////vagrant/.vagrant-puppet/files/etc/icinga2/conf.d/test-config.conf', owner => 'icinga',