Skip to content

Commit

Permalink
fix #244 specific-version for icinga2
Browse files Browse the repository at this point in the history
  • Loading branch information
lbetz committed Mar 15, 2017
1 parent da82427 commit e328af3
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 15 deletions.
22 changes: 20 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ and `notification` are enabled by default.

By default, your distribution's packages are used to install Icinga 2. On Windows systems we use the [Chocolatey]
package manager.

Use the `manage_repo` parameter to configure the official [packages.icinga.com] repositories.

``` puppet
Expand All @@ -95,6 +95,21 @@ class { '::icinga2':
}
```

If you wanna manage the version of Icinga 2 binaries you can do it by disable package management.

``` puppet
package { 'icinga2':
ensure => latest,
notifiy => Class['icinga2'],
}
class { '::icinga2':
manage_package => false,
}
```

Set `manage_package` to false means that all package aren't handeld by the module included the IDO packages.

### Enabling Features

There are two options how you can enable features:
Expand Down Expand Up @@ -763,7 +778,10 @@ If set to `true` the Icinga 2 service will start on boot. Defaults to `true`.
When set to `true` this module will install the [packages.icinga.com] repository. With this official repo
you can get the latest version of Icinga. When set to `false` the operating systems default will be used. As the Icinga
Project does not offer a [Chocolatey] repository, you will get a warning if you enable this parameter on Windows.
Default is `false`
Default is `false`. NOTE: will be ignored if manage_package is set to false.

##### `manage_package`
If set to false packages aren't managed. Defaults to true.

##### `manage_service`
Lets you decide if the Icinga 2 daemon should be reloaded when configuration files have changed. Defaults to `true`
Expand Down
7 changes: 7 additions & 0 deletions examples/init_package.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package { 'icinga2':
ensure => latest,
}
~>
class { '::icinga2':
manage_package => false,
}
9 changes: 9 additions & 0 deletions examples/init_package_idomysql.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package { ['icinga2', 'icinga2-ido-mysql']:
ensure => latest,
}
~>
class { 'icinga2':
manage_package => false,
}

include icinga2::feature::idomysql
15 changes: 15 additions & 0 deletions examples/init_package_idopgsql.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package { ['icinga2', 'icinga2-ido-pgsql']:
ensure => latest,
}
~>
class{ 'icinga2':
manage_package => false,
}

class{ 'icinga2::feature::idopgsql':
host => "127.0.0.1",
user => "icinga2",
password => "icinga2",
database => "icinga2",
import_schema => true
}
5 changes: 3 additions & 2 deletions manifests/feature/idomysql.pp
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@
$conf_dir = $::icinga2::params::conf_dir
$ssl_dir = "${::icinga2::params::pki_dir}/ido-mysql"
$ido_mysql_package = $::icinga2::params::ido_mysql_package
$manage_package = $::icinga2::manage_package

File {
owner => $owner,
Expand Down Expand Up @@ -304,7 +305,7 @@
}

# install additional package
if $ido_mysql_package {
if $ido_mysql_package and $manage_package {
package { $ido_mysql_package:
ensure => installed,
before => Icinga2::Feature['ido-mysql'],
Expand All @@ -313,7 +314,7 @@

# import db schema
if $import_schema {
if $ido_mysql_package {
if $ido_mysql_package and $manage_package {
Package[$ido_mysql_package] -> Exec['idomysql-import-schema']
}
exec { 'idomysql-import-schema':
Expand Down
5 changes: 3 additions & 2 deletions manifests/feature/idopgsql.pp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@

$conf_dir = $::icinga2::params::conf_dir
$ido_pgsql_package = $::icinga2::params::ido_pgsql_package
$manage_package = $::icinga2::manage_package

validate_re($ensure, [ '^present$', '^absent$' ],
"${ensure} isn't supported. Valid values are 'present' and 'absent'.")
Expand Down Expand Up @@ -125,7 +126,7 @@
}

# install additional package
if $ido_pgsql_package {
if $ido_pgsql_package and $manage_package {
package { $ido_pgsql_package:
ensure => installed,
before => Icinga2::Feature['ido-pgsql'],
Expand All @@ -134,7 +135,7 @@

# import db schema
if $import_schema {
if $ido_pgsql_package {
if $ido_pgsql_package and $manage_package {
Package[$ido_pgsql_package] -> Exec['idopgsql-import-schema']
}
exec { 'idopgsql-import-schema':
Expand Down
7 changes: 6 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
# When set to true this module will install the packages.icinga.com repository. With this official repo you can get
# the latest version of Icinga. When set to false the operating systems default will be used. As the Icinga Project
# does not offer a Chocolatey repository, you will get a warning if you enable this parameter on Windows.
# Defaults to false
# Defaults to false. NOTE: will be ignored if manage_package is set to false.
#
# [*manage_package*]
# If set to false packages aren't managed. Defaults to true.
#
# [*manage_service*]
# If set to true the service is managed otherwise the service also
Expand Down Expand Up @@ -125,6 +128,7 @@
$ensure = running,
$enable = true,
$manage_repo = false,
$manage_package = true,
$manage_service = true,
$features = $icinga2::params::default_features,
$purge_features = true,
Expand All @@ -137,6 +141,7 @@
"${ensure} isn't supported. Valid values are 'running' and 'stopped'.")
validate_bool($enable)
validate_bool($manage_repo)
validate_bool($manage_package)
validate_bool($manage_service)
validate_array($features)
validate_bool($purge_features)
Expand Down
15 changes: 8 additions & 7 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -18,36 +18,37 @@
fail("icinga2::install is a private class of the module icinga2, you're not permitted to use it.")
}

if $::osfamily == 'windows' { Package { provider => chocolatey, } }

$package = $::icinga2::params::package
$conf_dir = $::icinga2::params::conf_dir
$purge_features = $::icinga2::purge_features
$manage_package = $::icinga2::manage_package
$pki_dir = $::icinga2::params::pki_dir
$user = $::icinga2::params::user
$group = $::icinga2::params::group

package { $package:
ensure => installed,
if $manage_package {
if $::osfamily == 'windows' { Package { provider => chocolatey, } }

package { $package:
ensure => installed,
before => File["${conf_dir}/features-enabled", $pkidir],
}
}

file { "${conf_dir}/features-enabled":
ensure => directory,
purge => $purge_features,
recurse => $purge_features,
require => Package[$package],
}

# anchor, i.e. for config directory set by confd parameter
file { $conf_dir:
ensure => directory,
require => Package[$package]
}
file { $pki_dir:
ensure => directory,
owner => $user,
group => $group,
recurse => true,
require => Package[$package]
}
}
2 changes: 1 addition & 1 deletion manifests/repo.pp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
fail("icinga2::repo is a private class of the module icinga2, you're not permitted to use it.")
}

if $::icinga2::manage_repo {
if $::icinga2::manage_repo and $::icinga2::manage_package {

case $::osfamily {
'redhat': {
Expand Down

0 comments on commit e328af3

Please sign in to comment.