Skip to content

Commit

Permalink
rework module director
Browse files Browse the repository at this point in the history
  • Loading branch information
lbetz committed Nov 7, 2023
1 parent 72a4567 commit bdc8fbd
Show file tree
Hide file tree
Showing 12 changed files with 351 additions and 314 deletions.
74 changes: 74 additions & 0 deletions 3
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# @summary
# Configure the director module.
#
# @api private
#
class icingaweb2::module::director::config {
assert_private()

$stdlib_version = $icingaweb2::globals::stdlib_version
$icingacli_bin = $icingaweb2::globals::icingacli_bin
$install_method = $icingaweb2::module::director::install_method
$db = $icingaweb2::module::director::db
$import_schema = $icingaweb2::module::director::import_schema
$use_tls = $icingaweb2::module::director::use_tls
$tls = $icingaweb2::module::director::tls + {
cacert_file => icingaweb2::pick($icingaweb2::module::director::tls['cacert_file'], $icingaweb2::config::tls['cacert_file']),
capath => icingaweb2::pick($icingaweb2::module::director::tls_capath, $icingaweb2::config::tls['capath']),
noverify => icingaweb2::pick($icingaweb2::module::director::tls_noverify, $icingaweb2::config::tls['noverify']),
cipher => icingaweb2::pick($icingaweb2::module::director::tls_cipher, $icingaweb2::config::tls['cipher']),
}
$settings = $icingaweb2::module::director::db_settings + $icingaweb2::module::director::kickstart_settings
$service_user = $icingaweb2::module::director::service_user
$import_schema = $icingaweb2::module::director::import_schema
$kickstart = $icingaweb2::module::director::kickstart

Exec {
user => 'root',
path => $facts['path'],
provider => 'shell',
}

icingaweb2::resource::database { 'icingaweb2-module-director':
type => $db['type'],
host => $db['host'],
port => $db['port'],
database => $db['database'],
username => $db['username'],
password => $db['password'],
charset => pick($icingaweb2::module::director::db_charset, $icingaweb2::globals::db_charset[$db['type']]['director']),
use_tls => $use_tls,
tls_noverify => $tls['noverify'],
tls_key => $tls['key_file'],
tls_cert => $tls['cert_file'],
tls_cacert => $tls['cacert_file'],
tls_capath => $tls['capath'],
tls_cipher => $tls['cipher'],
}

create_resources('icingaweb2::inisection', $settings)

if $install_method == 'git' {
systemd::unit_file { 'icinga-director.service':
content => epp('icingaweb2/icinga-director.service.epp', {
'conf_user' => $service_user,
'icingacli_bin' => $icingacli_bin,
}),
}
}

if $import_schema {
exec { 'director-migration':
command => "${icingacli_bin} director migration run",
onlyif => "${icingacli_bin} director migration pending",
}

if $kickstart {
exec { 'director-kickstart':
command => "${icingacli_bin} director kickstart run",
onlyif => "${icingacli_bin} director kickstart required",
require => Exec['director-migration'],
}
}
}
}
96 changes: 20 additions & 76 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
* [`icingaweb2::module::audit`](#icingaweb2--module--audit): Installs and enables the audit module.
* [`icingaweb2::module::businessprocess`](#icingaweb2--module--businessprocess): Installs and enables the businessprocess module.
* [`icingaweb2::module::cube`](#icingaweb2--module--cube): Installs and enables the cube module.
* [`icingaweb2::module::director`](#icingaweb2--module--director): Installs and configures the director module.
* [`icingaweb2::module::director::service`](#icingaweb2--module--director--service): Installs and configures the director service.
* [`icingaweb2::module::director`](#icingaweb2--module--director): Install and configure the director module.
* [`icingaweb2::module::doc`](#icingaweb2--module--doc): The doc module provides an interface to the Icinga 2 and Icinga Web 2 documentation.
* [`icingaweb2::module::elasticsearch`](#icingaweb2--module--elasticsearch): The Elasticsearch module displays events from data stored in Elasticsearch.
* [`icingaweb2::module::fileshipper`](#icingaweb2--module--fileshipper): The fileshipper module extends the Director. It offers import sources to deal with CSV, JSON, YAML and XML files.
Expand All @@ -38,6 +37,9 @@

* `icingaweb2::config`: Configures Icinga Web 2.
* `icingaweb2::install`: Installs Icinga Web 2 and extra packages.
* `icingaweb2::module::director::config`: Configure the director module.
* `icingaweb2::module::director::install`: Install the director module.
* `icingaweb2::module::director::service`: Manage the director service.
* `icingaweb2::module::icingadb::config`: Configure the icingadb module.
* `icingaweb2::module::icingadb::install`: Install the icingadb module.
* `icingaweb2::module::monitoring::config`: Configure the monitoring module.
Expand Down Expand Up @@ -989,7 +991,7 @@ Default value: `'icingaweb2-module-cube'`

### <a name="icingaweb2--module--director"></a>`icingaweb2::module::director`

Installs and configures the director module.
Install and configure the director module.

* **Note** If you want to use `git` as `install_method`, the CLI `git` command has to be installed. You can manage it yourself as package resource or declare the package name in icingaweb2 class parameter `extra_packages`.

Expand Down Expand Up @@ -1048,31 +1050,30 @@ The following parameters are available in the `icingaweb2::module::director` cla
* [`api_username`](#-icingaweb2--module--director--api_username)
* [`api_password`](#-icingaweb2--module--director--api_password)
* [`manage_service`](#-icingaweb2--module--director--manage_service)
* [`service_ensure`](#-icingaweb2--module--director--service_ensure)
* [`service_enable`](#-icingaweb2--module--director--service_enable)
* [`service_user`](#-icingaweb2--module--director--service_user)

##### <a name="-icingaweb2--module--director--ensure"></a>`ensure`

Data type: `Enum['absent', 'present']`

Enable or disable module.

Default value: `'present'`

##### <a name="-icingaweb2--module--director--module_dir"></a>`module_dir`

Data type: `Optional[Stdlib::Absolutepath]`
Data type: `Stdlib::Absolutepath`

Target directory of the module.

Default value: `undef`
Default value: `"${icingaweb2::globals::default_module_path}/director"`

##### <a name="-icingaweb2--module--director--git_repository"></a>`git_repository`

Data type: `String`
Data type: `Stdlib::HTTPUrl`

Set a git repository URL.

Default value: `'https://github.com/Icinga/icingaweb2-module-director.git'`

##### <a name="-icingaweb2--module--director--git_revision"></a>`git_revision`

Data type: `Optional[String]`
Expand All @@ -1087,16 +1088,12 @@ Data type: `Enum['git', 'package', 'none']`

Install methods are `git`, `package` and `none` is supported as installation method.

Default value: `'git'`

##### <a name="-icingaweb2--module--director--package_name"></a>`package_name`

Data type: `String`

Package name of the module. This setting is only valid in combination with the installation method `package`.

Default value: `'icingaweb2-module-director'`

##### <a name="-icingaweb2--module--director--db_type"></a>`db_type`

Data type: `Enum['mysql', 'pgsql']`
Expand All @@ -1109,8 +1106,6 @@ Data type: `Stdlib::Host`

Hostname of the database.

Default value: `'localhost'`

##### <a name="-icingaweb2--module--director--db_port"></a>`db_port`

Data type: `Optional[Stdlib::Port]`
Expand All @@ -1125,16 +1120,12 @@ Data type: `String`

Name of the database.

Default value: `'director'`

##### <a name="-icingaweb2--module--director--db_username"></a>`db_username`

Data type: `String`

Username for DB connection.

Default value: `'director'`

##### <a name="-icingaweb2--module--director--db_password"></a>`db_password`

Data type: `Optional[Icingaweb2::Secret]`
Expand All @@ -1145,11 +1136,11 @@ Default value: `undef`

##### <a name="-icingaweb2--module--director--db_charset"></a>`db_charset`

Data type: `String`
Data type: `Optional[String]`

Character set to use for the database.

Default value: `'utf8'`
Default value: `undef`

##### <a name="-icingaweb2--module--director--use_tls"></a>`use_tls`

Expand Down Expand Up @@ -1263,16 +1254,12 @@ Data type: `Stdlib::Host`

Icinga 2 API hostname. This setting is only valid if `kickstart` is `true`.

Default value: `'localhost'`

##### <a name="-icingaweb2--module--director--api_port"></a>`api_port`

Data type: `Stdlib::Port`

Icinga 2 API port. This setting is only valid if `kickstart` is `true`.

Default value: `5665`

##### <a name="-icingaweb2--module--director--api_username"></a>`api_username`

Data type: `Optional[String]`
Expand All @@ -1293,68 +1280,25 @@ Default value: `undef`

Data type: `Boolean`

Also manage the service (daemon), running and enabled. Otherwise do your config via hiera.

Default value: `true`

### <a name="icingaweb2--module--director--service"></a>`icingaweb2::module::director::service`

Installs and configures the director service.

* **Note** Only systemd is supported by the Icinga Team and this module.

#### Parameters

The following parameters are available in the `icingaweb2::module::director::service` class:

* [`ensure`](#-icingaweb2--module--director--service--ensure)
* [`enable`](#-icingaweb2--module--director--service--enable)
* [`user`](#-icingaweb2--module--director--service--user)
* [`group`](#-icingaweb2--module--director--service--group)
* [`manage_user`](#-icingaweb2--module--director--service--manage_user)
If set to true the service (daemon) is managed.

##### <a name="-icingaweb2--module--director--service--ensure"></a>`ensure`
##### <a name="-icingaweb2--module--director--service_ensure"></a>`service_ensure`

Data type: `Stdlib::Ensure::Service`

Whether the director service should be running.

Default value: `'running'`
Wether the service is `running` or `stopped`.

##### <a name="-icingaweb2--module--director--service--enable"></a>`enable`
##### <a name="-icingaweb2--module--director--service_enable"></a>`service_enable`

Data type: `Boolean`

Enable or disable the service.

Default value: `true`

##### <a name="-icingaweb2--module--director--service--user"></a>`user`

Data type: `String`

Specifies user to run director service daemon. Only available if
install_method package is not used.

Default value: `'icingadirector'`
Whether the service should be started at boot time.

##### <a name="-icingaweb2--module--director--service--group"></a>`group`
##### <a name="-icingaweb2--module--director--service_user"></a>`service_user`

Data type: `String`

Specifies primary group for user to run director service daemon.
Only available if install_method package is not used.

Default value: `'icingaweb2'`

##### <a name="-icingaweb2--module--director--service--manage_user"></a>`manage_user`

Data type: `Boolean`

Whether to manage the server user resource. Only available if
install_method package is not used.

Default value: `true`
The user as which the service is running. Only valid if `install_method` is set to `git`.

### <a name="icingaweb2--module--doc"></a>`icingaweb2::module::doc`

Expand Down
2 changes: 2 additions & 0 deletions data/Linux-kernel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,7 @@ icingaweb2::conf_group: icingaweb2
icingaweb2::logging_file: /var/log/icingaweb2/icingaweb2.log

icingaweb2::module::icingadb::package_name: icingadb-web
icingaweb2::module::director::package_name: icingaweb2-module-director
icingaweb2::module::reporting::package_name: icingaweb2-module-reporting
icingaweb2::module::idoreports::package_name: icingaweb2-module-idoreports
icingaweb2::module::vspheredb::package_name: icingaweb2-module-vspheredb
22 changes: 17 additions & 5 deletions data/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,13 @@ icingaweb2::default_admin_password: icinga
icingaweb2::globals::role_replace: true
icingaweb2::module::businessprocess::git_repository: https://github.com/Icinga/icingaweb2-module-businessprocess.git
icingaweb2::module::cube::git_repository: https://github.com/Icinga/icingaweb2-module-cube.git
icingaweb2::module::director::git_repository: https://github.com/Icinga/icingaweb2-module-director.git
icingaweb2::module::elasticsearch::git_repository: https://github.com/Icinga/icingaweb2-module-elasticsearch.git
icingaweb2::module::fileshipper::git_repository: https://github.com/Icinga/icingaweb2-module-fileshipper.git
icingaweb2::module::generictts::git_repository: https://github.com/Icinga/icingaweb2-module-generictts.git
icingaweb2::module::graphite::git_repository: https://github.com/Icinga/icingaweb2-module-graphite.git
icingaweb2::module::incubator::git_repository: https://github.com/Icinga/icingaweb2-module-incubator.git
icingaweb2::module::incubator::git_revision: v0.19.0
icingaweb2::module::puppetdb::git_repository: https://github.com/Icinga/icingaweb2-module-puppetdb.git
icingaweb2::module::idoreports::ensure: present
icingaweb2::module::idoreports::install_method: git
icingaweb2::module::idoreports::git_repository: https://github.com/Icinga/icingaweb2-module-idoreports.git
icingaweb2::module::idoreports::package_name: icingaweb2-module-idoreports
icingaweb2::module::x509::ensure: present
icingaweb2::module::x509::install_method: git
icingaweb2::module::x509::git_repository: https://github.com/Icinga/icingaweb2-module-x509.git
Expand All @@ -39,6 +34,19 @@ icingaweb2::module::icingadb::db_host: localhost
icingaweb2::module::icingadb::db_name: icingadb
icingaweb2::module::icingadb::db_username: icingadb

icingaweb2::module::director::ensure: present
icingaweb2::module::director::install_method: git
icingaweb2::module::director::git_repository: https://github.com/Icinga/icingaweb2-module-director.git
icingaweb2::module::director::api_host: localhost
icingaweb2::module::director::api_port: 5665
icingaweb2::module::director::manage_service: true
icingaweb2::module::director::service_ensure: running
icingaweb2::module::director::service_enable: true
icingaweb2::module::director::service_user: icingadirector
icingaweb2::module::director::db_host: localhost
icingaweb2::module::director::db_name: director
icingaweb2::module::director::db_username: director

icingaweb2::globals::mysql_reporting_schema: /schema/mysql.sql
icingaweb2::globals::pgsql_reporting_schema: /schema/postgresql.sql
icingaweb2::module::reporting::ensure: present
Expand All @@ -52,6 +60,10 @@ icingaweb2::module::reporting::db_host: localhost
icingaweb2::module::reporting::db_name: reporting
icingaweb2::module::reporting::db_username: reporting

icingaweb2::module::idoreports::ensure: present
icingaweb2::module::idoreports::install_method: git
icingaweb2::module::idoreports::git_repository: https://github.com/Icinga/icingaweb2-module-idoreports.git

icingaweb2::globals::mysql_vspheredb_schema: /schema/mysql.sql
icingaweb2::globals::pgsql_vspheredb_schema: /schema/pgsql.sql
icingaweb2::module::vspheredb::ensure: present
Expand Down
2 changes: 2 additions & 0 deletions manifests/globals.pp
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,12 @@

$db_charset = {
'mysql' => {
'director' => 'utf8',
'vspheredb' => 'utf8mb4',
'reporting' => 'utf8mb4',
},
'pgsql' => {
'director' => 'UTF8',
'vspheredb' => 'UTF8',
'reporting' => 'UTF8',
},
Expand Down
Loading

0 comments on commit bdc8fbd

Please sign in to comment.