diff --git a/manifests/config.pp b/manifests/config.pp index 70faa93..1230b5e 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -1,176 +1,180 @@ # == Class: icingaweb2::config # # This class manages general configuration files of Icinga Web 2. # # === Parameters # # This class does not provide any parameters. # # === Examples # # This class is private and should not be called by others than this module. # class icingaweb2::config { $conf_dir = $::icingaweb2::params::conf_dir $conf_user = $::icingaweb2::conf_user $conf_group = $::icingaweb2::params::conf_group $logging = $::icingaweb2::logging $logging_file = $::icingaweb2::logging_file $logging_dir = dirname($::icingaweb2::logging_file) $logging_level = $::icingaweb2::logging_level + $logging_facility = $::icingaweb2::logging_facility + $logging_application = $::icingaweb2::logging_application $show_stacktraces = $::icingaweb2::show_stacktraces $module_path = $::icingaweb2::module_path $theme = $::icingaweb2::theme $theme_disabled = $::icingaweb2::theme_disabled $import_schema = $::icingaweb2::import_schema $schema_dir = $::icingaweb2::params::schema_dir $db_name = $::icingaweb2::db_name $db_host = $::icingaweb2::db_host $db_port = $::icingaweb2::db_port $db_type = $::icingaweb2::db_type $db_username = $::icingaweb2::db_username $db_password = $::icingaweb2::db_password $default_domain = $::icingaweb2::default_domain $config_backend = $::icingaweb2::config_backend $config_resource = $::icingaweb2::config_backend ? { 'ini' => undef, 'db' => "${db_type}-icingaweb2", } File { mode => '0660', owner => $conf_user, group => $conf_group } Exec { user => 'root', path => $::path, } file { $logging_dir: ensure => directory, mode => '0750', } file { $logging_file: ensure => file, mode => '0640', } icingaweb2::inisection { 'config-logging': section_name => 'logging', target => "${conf_dir}/config.ini", settings => { - 'log' => $logging, - 'file' => $logging_file, - 'level' => $logging_level + 'log' => $logging, + 'file' => $logging_file, + 'level' => $logging_level, + 'facility' => $logging_facility, + 'application' => $logging_application, }, } $settings = { 'show_stacktraces' => $show_stacktraces, 'module_path' => $module_path, 'config_backend' => $config_backend, 'config_resource' => $config_resource, } icingaweb2::inisection { 'config-global': section_name => 'global', target => "${conf_dir}/config.ini", settings => delete_undef_values($settings), } if $default_domain { icingaweb2::inisection { 'config-authentication': section_name => 'authentication', target => "${conf_dir}/config.ini", settings => { 'default_domain' => $default_domain, } } } icingaweb2::inisection { 'config-themes': section_name => 'themes', target => "${conf_dir}/config.ini", settings => { 'default' => $theme, 'disabled' => $theme_disabled, }, } file { "${conf_dir}/modules": ensure => 'directory' } file { "${conf_dir}/enabledModules": ensure => 'directory' } if $import_schema or $config_backend == 'db' { icingaweb2::config::resource { "${db_type}-icingaweb2": type => 'db', host => $db_host, port => $db_port, db_type => $db_type, db_name => $db_name, db_username => $db_username, db_password => $db_password, } } if $import_schema { icingaweb2::config::authmethod { "${db_type}-auth": backend => 'db', resource => "${db_type}-icingaweb2" } icingaweb2::config::role { 'default admin user': users => 'icingaadmin', permissions => '*', } icingaweb2::config::groupbackend { "${db_type}-group": backend => 'db', resource => "${db_type}-icingaweb2" } case $db_type { 'mysql': { exec { 'import schema': command => "mysql -h '${db_host}' -P '${db_port}' -u '${db_username}' -p'${db_password}' '${db_name}' < '${schema_dir}/mysql.schema.sql'", unless => "mysql -h '${db_host}' -P '${db_port}' -u '${db_username}' -p'${db_password}' '${db_name}' -Ns -e 'SELECT 1 FROM icingaweb_user'", notify => Exec['create default user'], } exec { 'create default user': command => "mysql -h '${db_host}' -P '${db_port}' -u '${db_username}' -p'${db_password}' '${db_name}' -Ns -e 'INSERT INTO icingaweb_user (name, active, password_hash) VALUES (\"icingaadmin\", 1, \"\$1\$3no6eqZp\$FlcHQDdnxGPqKadmfVcCU.\")'", refreshonly => true, } } 'pgsql': { exec { 'import schema': environment => ["PGPASSWORD=${db_password}"], command => "psql -h '${db_host}' -p '${db_port}' -U '${db_username}' -d '${db_name}' -w -f ${schema_dir}/pgsql.schema.sql", unless => "psql -h '${db_host}' -p '${db_port}' -U '${db_username}' -d '${db_name}' -w -c 'SELECT 1 FROM icingaweb_user'", notify => Exec['create default user'], } exec { 'create default user': environment => ["PGPASSWORD=${db_password}"], command => "psql -h '${db_host}' -p '${db_port}' -U '${db_username}' -d '${db_name}' -w -c \"INSERT INTO icingaweb_user(name, active, password_hash) VALUES ('icingaadmin', 1, '\\\$1\\\$3no6eqZp\\\$FlcHQDdnxGPqKadmfVcCU.')\"", refreshonly => true, } } default: { fail('The database type you provided is not supported.') } } } } diff --git a/manifests/init.pp b/manifests/init.pp index 2eb448a..2dd7fd9 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,109 +1,117 @@ # == Class: icingaweb2 # # This module installs and configures Icinga Web 2. # # === Parameters # # [*logging*] # Whether Icinga Web 2 should log to 'file' or to 'syslog'. Setting 'none' disables logging. Defaults to 'file'. # # [*logging_file*] # If 'logging' is set to 'file', this is the target log file. Defaults to '/var/log/icingaweb2/icingaweb2.log'. # # [*logging_level*] # Logging verbosity. Possible values are 'ERROR', 'WARNING', 'INFO' and 'DEBUG'. Defaults to 'INFO'. # +# [*logging_facility*] +# Logging facility when using syslog. Possible values are 'user' or 'local0' to 'local7'. +# +# [*logging_application*] +# Logging application name when using syslog. +# # [*enable_stacktraces*] # Whether to display stacktraces in the web interface or not. Defaults to 'false'. # # [*module_path*] # Path to module sources. Multiple paths must be separated by colon. Defaults to '/usr/share/icingaweb2/modules'. # # [*theme*] # The default theme setting. Users may override this settings. Defaults to 'icinga'. # # [*theme_disabled*] # Whether users can change themes or not. Defaults to `false`. # # [*manage_repo*] # 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 Web. When set to false the operating systems default will be used. 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`. # # [*extra_pacakges*] # An array of packages to install additionally. # # [*import_schema*] # Import database scheme. Make sure you have an existing database if you use this option. Defaults to `false` # # [*db_type*] # Database type, can be either `mysql` or `pgsql`. This parameter is only used if `import_schema` is `true` or # `config_backend` is `db`. Defaults to `mysql` # # [*db_host*] # Database hostname. This parameter is only used if `import_schema` is `true` or # `config_backend` is `db`. Defaults to `localhost` # # [*db_port*] # Port of database host. This parameter is only used if `import_schema` is `true` or # `config_backend` is `db`. Defaults to `3306` # # [*db_name*] # Database name. This parameter is only used if `import_schema` is `true` or # `config_backend` is `db`. Defaults to `icingaweb2` # # [*db_username*] # Username for database access. This parameter is only used if `import_schema` is `true` or # `config_backend` is `db`. # # [*db_password*] # Password for database access. This parameter is only used if `import_schema` is `true` or # `config_backend` is `db`. # # [*config_backend*] # The global Icinga Web 2 preferences can either be stored in a database or in ini files. This parameter can either # be set to `db` or `ini`. Defaults to `ini` # # [*conf_user*] # By default this module expects Apache2 on the server. You can change the owner of the config files with this # parameter. Default is dependent on the platform # # [*default_domain*] # When using domain-aware authentication, you can set a default domain here. # # === Examples # # class icingaweb2 ( Enum['file', 'syslog', 'none'] $logging = 'file', Stdlib::Absolutepath $logging_file = '/var/log/icingaweb2/icingaweb2.log', Enum['ERROR', 'WARNING', 'INFO', 'DEBUG'] $logging_level = 'INFO', + Pattern[/user|local[0-7]/] $logging_facility = 'user', + String $logging_application = 'icingaweb2', Boolean $show_stacktraces = false, Stdlib::Absolutepath $module_path = $::icingaweb2::params::module_path, String $theme = 'Icinga', Boolean $theme_disabled = false, Boolean $manage_repo = false, Boolean $manage_package = true, Optional[Array[String]] $extra_packages = undef, Boolean $import_schema = false, Enum['mysql', 'pgsql'] $db_type = 'mysql', String $db_host = 'localhost', Integer[1,65535] $db_port = 3306, String $db_name = 'icingaweb2', Optional[String] $db_username = undef, Optional[String] $db_password = undef, Enum['ini', 'db'] $config_backend = 'ini', String $conf_user = $icingaweb2::params::conf_user, Optional[String] $default_domain = undef, ) inherits ::icingaweb2::params { anchor { '::icingaweb2::begin': } -> class { '::icingaweb2::repo': } -> class { '::icingaweb2::install': } -> class { '::icingaweb2::config': } -> anchor { '::icingaweb2::end': } }