From a326ecd7add849325e882d9668c2bb46be7db442 Mon Sep 17 00:00:00 2001 From: Lennart Betz Date: Tue, 26 Jul 2022 15:41:35 +0200 Subject: [PATCH] fix #65 Add parameter for initial admin user and password to Icinga Web 2 --- examples/mysql/standalone.pp | 18 ++++++------ examples/pgsql/standalone.pp | 18 ++++++------ manifests/web.pp | 56 +++++++++++++++++++++--------------- 3 files changed, 53 insertions(+), 39 deletions(-) diff --git a/examples/mysql/standalone.pp b/examples/mysql/standalone.pp index f7a235c..716851b 100644 --- a/examples/mysql/standalone.pp +++ b/examples/mysql/standalone.pp @@ -20,14 +20,16 @@ } class { '::icinga::web': - backend_db_type => $icinga::ido::db_type, - backend_db_host => $icinga::ido::db_host, - backend_db_pass => $icinga::ido::db_pass, - db_type => 'mysql', - db_host => 'localhost', - db_pass => 'icingaweb2', - manage_database => true, - api_pass => $icinga::server::web_api_pass, + backend_db_type => $icinga::ido::db_type, + backend_db_host => $icinga::ido::db_host, + backend_db_pass => $icinga::ido::db_pass, + db_type => 'mysql', + db_host => 'localhost', + db_pass => 'icingaweb2', + default_admin_user => 'admin', + default_admin_pass => 'admin', + manage_database => true, + api_pass => $icinga::server::web_api_pass, } class { '::icinga::web::director': diff --git a/examples/pgsql/standalone.pp b/examples/pgsql/standalone.pp index 2dea91f..75b3898 100644 --- a/examples/pgsql/standalone.pp +++ b/examples/pgsql/standalone.pp @@ -20,14 +20,16 @@ } class { '::icinga::web': - backend_db_type => $icinga::ido::db_type, - backend_db_host => $icinga::ido::db_host, - backend_db_pass => $icinga::ido::db_pass, - db_type => 'pgsql', - db_host => 'localhost', - db_pass => 'icingaweb2', - manage_database => true, - api_pass => $icinga::server::web_api_pass, + backend_db_type => $icinga::ido::db_type, + backend_db_host => $icinga::ido::db_host, + backend_db_pass => $icinga::ido::db_pass, + db_type => 'pgsql', + db_host => 'localhost', + db_pass => 'icingaweb2', + default_admin_user => 'admin', + default_admin_pass => 'admin', + manage_database => true, + api_pass => $icinga::server::web_api_pass, } class { '::icinga::web::director': diff --git a/manifests/web.pp b/manifests/web.pp index 4d81e9b..347147f 100644 --- a/manifests/web.pp +++ b/manifests/web.pp @@ -1,6 +1,12 @@ # @summary # Setup Icinga Web 2 including a database backend for user settings. # +# @param default_admin_user +# Set the initial name of the admin user. +# +# @param default_admin_pass +# Set the initial password for the admin user. +# # @param db_pass # Password to connect the database. # @@ -58,19 +64,21 @@ String $api_pass, Boolean $apache_cgi_pass_auth, String $backend_db_pass, - Enum['mysql', 'pgsql'] $db_type = 'mysql', - Stdlib::Host $db_host = 'localhost', - Optional[Stdlib::Port::Unprivileged] $db_port = undef, - String $db_name = 'icingaweb2', - String $db_user = 'icingaweb2', - Boolean $manage_database = false, - Variant[Stdlib::Host, Array[Stdlib::Host]] $api_host = 'localhost', - String $api_user = 'icingaweb2', - Enum['mysql', 'pgsql'] $backend_db_type = 'mysql', - Stdlib::Host $backend_db_host = 'localhost', - Optional[Stdlib::Port::Unprivileged] $backend_db_port = undef, - String $backend_db_name = 'icinga2', - String $backend_db_user = 'icinga2', + String $default_admin_user = 'icingaadmin', + String $default_admin_pass = 'icingaadmin', + Enum['mysql', 'pgsql'] $db_type = 'mysql', + Stdlib::Host $db_host = 'localhost', + Optional[Stdlib::Port::Unprivileged] $db_port = undef, + String $db_name = 'icingaweb2', + String $db_user = 'icingaweb2', + Boolean $manage_database = false, + Variant[Stdlib::Host, Array[Stdlib::Host]] $api_host = 'localhost', + String $api_user = 'icingaweb2', + Enum['mysql', 'pgsql'] $backend_db_type = 'mysql', + Stdlib::Host $backend_db_host = 'localhost', + Optional[Stdlib::Port::Unprivileged] $backend_db_port = undef, + String $backend_db_name = 'icinga2', + String $backend_db_user = 'icinga2', ) { unless $backend_db_port { @@ -234,16 +242,18 @@ # Icinga Web 2 # class { 'icingaweb2': - db_type => $db_type, - db_host => $_db_host, - db_port => $_db_port, - db_name => $db_name, - db_username => $db_user, - db_password => $db_pass, - import_schema => lookup('icingaweb2::import_schema', undef, undef, true), - config_backend => 'db', - conf_user => $web_conf_user, - manage_package => $manage_package, + db_type => $db_type, + db_host => $_db_host, + db_port => $_db_port, + db_name => $db_name, + db_username => $db_user, + db_password => $db_pass, + default_admin_username => $default_admin_user, + default_admin_password => $default_admin_pass, + import_schema => lookup('icingaweb2::import_schema', undef, undef, true), + config_backend => 'db', + conf_user => $web_conf_user, + manage_package => $manage_package, } class { '::icingaweb2::module::monitoring':