diff --git a/README.md b/README.md index d0be9a14..afe5feb0 100644 --- a/README.md +++ b/README.md @@ -103,7 +103,6 @@ class { 'icingaweb2': db_port => 3306, db_username => 'icingaweb2', db_password => 'supersecret', - config_backend => 'db', extra_packages => [ 'git' ], require => Mysql::Db['icingaweb2'], } diff --git a/REFERENCE.md b/REFERENCE.md index 2cffe617..2eb373ac 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -209,7 +209,6 @@ The following parameters are available in the `icingaweb2` class: * [`tls_capath`](#-icingaweb2--tls_capath) * [`tls_noverify`](#-icingaweb2--tls_noverify) * [`tls_cipher`](#-icingaweb2--tls_cipher) -* [`config_backend`](#-icingaweb2--config_backend) * [`conf_user`](#-icingaweb2--conf_user) * [`conf_group`](#-icingaweb2--conf_group) * [`default_domain`](#-icingaweb2--default_domain) @@ -374,12 +373,10 @@ Default value: `'icingaweb2'` ##### `db_password` -Data type: `Optional[Icingaweb2::Secret]` +Data type: `Icingaweb2::Secret` Password for database access. -Default value: `undef` - ##### `use_tls` Data type: `Optional[Boolean]` @@ -462,15 +459,6 @@ Cipher to use for the encrypted database connection. Default value: `undef` -##### `config_backend` - -Data type: `Enum['ini', 'db']` - -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`. - -Default value: `'ini'` - ##### `conf_user` Data type: `String` diff --git a/manifests/config.pp b/manifests/config.pp index 3c3b301b..27d39417 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -43,11 +43,7 @@ $admin_role = $icingaweb2::admin_role $admin_username = $icingaweb2::default_admin_username $admin_password = icingaweb2::unwrap($icingaweb2::default_admin_password) - $config_backend = $icingaweb2::config_backend - $config_resource = $icingaweb2::config_backend ? { - 'ini' => undef, - 'db' => "${db['type']}-icingaweb2", - } + $config_resource = "${db['type']}-icingaweb2" $use_tls = $icingaweb2::use_tls $tls = icingaweb2::cert::files( @@ -103,7 +99,6 @@ $settings = { 'show_stacktraces' => $show_stacktraces, 'module_path' => join(unique([$default_module_path] + $module_path), ':'), - 'config_backend' => $config_backend, 'config_resource' => $config_resource, } @@ -183,36 +178,34 @@ } } - if $import_schema or $config_backend == 'db' { - icingaweb2::tls::client { 'icingaweb2 tls client config': - args => $tls, - } + icingaweb2::tls::client { 'icingaweb2 tls client config': + args => $tls, + } - -> icingaweb2::resource::database { "${db['type']}-icingaweb2": - type => $db['type'], - host => $db['host'], - port => $db['port'], - database => $db['name'], - username => $db['user'], - password => $db['pass'], - 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'], - } + -> icingaweb2::resource::database { "${db['type']}-icingaweb2": + type => $db['type'], + host => $db['host'], + port => $db['port'], + database => $db['name'], + username => $db['user'], + password => $db['pass'], + 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'], + } - icingaweb2::config::groupbackend { "${db['type']}-group": - backend => 'db', - resource => "${db['type']}-icingaweb2", - } + icingaweb2::config::groupbackend { "${db['type']}-group": + backend => 'db', + resource => "${db['type']}-icingaweb2", + } - icingaweb2::config::authmethod { "${db['type']}-auth": - backend => 'db', - resource => "${db['type']}-icingaweb2", - } + icingaweb2::config::authmethod { "${db['type']}-auth": + backend => 'db', + resource => "${db['type']}-icingaweb2", } if $import_schema { diff --git a/manifests/init.pp b/manifests/init.pp index 1425393a..8ca3b1b4 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -94,10 +94,6 @@ # @param tls_cipher # Cipher to use for the encrypted database connection. # -# @param 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`. -# # @param conf_user # By default this module expects Apache2 on the server. You can change the owner of the config files with this # parameter. @@ -213,6 +209,7 @@ Stdlib::Absolutepath $logging_file, String $conf_user, String $conf_group, + Icingaweb2::Secret $db_password, Variant[Icingaweb2::AdminRole, Boolean[false]] $admin_role, String $default_admin_username, Icingaweb2::Secret $default_admin_password, @@ -234,7 +231,6 @@ Optional[Stdlib::Port] $db_port = undef, String $db_name = 'icingaweb2', String $db_username = 'icingaweb2', - Optional[Icingaweb2::Secret] $db_password = undef, Optional[Boolean] $use_tls = undef, Optional[Stdlib::Absolutepath] $tls_key_file = undef, Optional[Stdlib::Absolutepath] $tls_cert_file = undef, @@ -245,7 +241,6 @@ Optional[String] $tls_cacert = undef, Optional[Boolean] $tls_noverify = undef, Optional[String] $tls_cipher = undef, - Enum['ini', 'db'] $config_backend = 'ini', Optional[String] $default_domain = undef, Optional[Stdlib::Absolutepath] $cookie_path = undef, Hash[String, Hash[String, Any]] $resources = {}, diff --git a/spec/classes/audit_spec.rb b/spec/classes/audit_spec.rb index 87d27894..c6c142f8 100644 --- a/spec/classes/audit_spec.rb +++ b/spec/classes/audit_spec.rb @@ -3,7 +3,7 @@ describe('icingaweb2::module::audit', type: :class) do let(:pre_condition) do [ - "class { 'icingaweb2': }", + "class { 'icingaweb2': db_type => 'mysql', db_password => 'secret' }", ] end diff --git a/spec/classes/businessprocess_spec.rb b/spec/classes/businessprocess_spec.rb index bf16bb17..f49bc4dd 100644 --- a/spec/classes/businessprocess_spec.rb +++ b/spec/classes/businessprocess_spec.rb @@ -3,7 +3,7 @@ describe('icingaweb2::module::businessprocess', type: :class) do let(:pre_condition) do [ - "class { 'icingaweb2': }", + "class { 'icingaweb2': db_type => 'mysql', db_password => 'secret' }", ] end diff --git a/spec/classes/config_spec.rb b/spec/classes/config_spec.rb index bccfe6ad..8087308c 100644 --- a/spec/classes/config_spec.rb +++ b/spec/classes/config_spec.rb @@ -7,15 +7,15 @@ facts end - context 'with default parameters' do + context 'with default parameters, db_type => mysql' do let :pre_condition do - "class { 'icingaweb2': }" + "class { 'icingaweb2': db_type => 'mysql', db_password => 'secret' }" end it { is_expected.to contain_icingaweb2__inisection('config-logging') } it { is_expected.to contain_icingaweb2__inisection('config-global') - .with_settings('show_stacktraces' => false, 'module_path' => '/usr/share/icingaweb2/modules', 'config_backend' => 'ini') + .with_settings('show_stacktraces' => false, 'module_path' => '/usr/share/icingaweb2/modules', 'config_resource' => 'mysql-icingaweb2') } it { is_expected.to contain_icingaweb2__inisection('config-themes') } it { is_expected.not_to contain_icingaweb2__inisection('config-cookie') } @@ -29,14 +29,16 @@ .with_ensure('file') .with_mode('0640') } + + it { is_expected.to contain_icingaweb2__resource__database('mysql-icingaweb2') } it { is_expected.not_to contain_exec('import schema') } it { is_expected.not_to contain_exec('create default admin user') } it { is_expected.not_to contain_icingaweb2__config__role('default admin user') } end - context 'with import_schema => true and db_type => mysql' do + context 'with db_type => mysql, import_schema => true' do let :pre_condition do - "class { 'icingaweb2': import_schema => true, db_type => 'mysql'}" + "class { 'icingaweb2': import_schema => true, db_type => 'mysql', db_password => 'secret' }" end it { is_expected.to contain_icingaweb2__resource__database('mysql-icingaweb2') } @@ -46,9 +48,9 @@ it { is_expected.to contain_exec('create default admin user') } end - context 'with import_schema => true and db_type => pgsql' do + context 'with db_type => pgsql, import_schema => true' do let :pre_condition do - "class { 'icingaweb2': import_schema => true, db_type => 'pgsql'}" + "class { 'icingaweb2': import_schema => true, db_type => 'pgsql', db_password => 'secret' }" end it { is_expected.to contain_icingaweb2__resource__database('pgsql-icingaweb2') } @@ -58,48 +60,25 @@ it { is_expected.to contain_exec('create default admin user') } end - context 'with import_schema => true and invalid db_type' do + context 'with invalid db_type' do let :pre_condition do - "class { 'icingaweb2': import_schema => true, db_type => 'foobar'}" + "class { 'icingaweb2': db_type => 'foobar', db_password => 'secret' }" end it { is_expected.to raise_error(Puppet::Error, %r{expects a match for Enum\['mysql', 'pgsql'\]}) } end - # context 'with import_schema => false' do - # let :pre_condition do - # "class { 'icingaweb2': import_schema => false }" - # end - - # it { is_expected.not_to contain_exec('import schema') } - # it { is_expected.not_to contain_exec('create default admin user') } - # it { is_expected.to contain_icingaweb2__config__role('default admin user') } - # end - context 'with import_schema => true and admin_role => false' do let :pre_condition do - "class { 'icingaweb2': import_schema => true, admin_role => false }" + "class { 'icingaweb2': import_schema => true, db_type => 'mysql', db_password => 'secret', admin_role => false }" end it { is_expected.not_to contain_icingaweb2__config__role('default admin user') } end - context 'with config_backend => db' do - let :pre_condition do - "class { 'icingaweb2': config_backend => 'db' }" - end - - it { - is_expected.to contain_icingaweb2__inisection('config-global') - .with_settings('show_stacktraces' => false, 'module_path' => '/usr/share/icingaweb2/modules', 'config_backend' => 'db', 'config_resource' => 'mysql-icingaweb2') - } - - it { is_expected.to contain_icingaweb2__resource__database('mysql-icingaweb2') } - end - context 'with cookie_path => /' do let :pre_condition do - "class { 'icingaweb2': cookie_path => '/' }" + "class { 'icingaweb2': cookie_path => '/', db_type => 'mysql', db_password => 'secret' }" end it { @@ -107,14 +86,6 @@ .with_settings('path' => '/') } end - - context 'with invalid config_backend' do - let :pre_condition do - "class { 'icingaweb2': config_backend => 'foobar' }" - end - - it { is_expected.to raise_error(Puppet::Error, %r{expects a match for Enum\['db', 'ini'\]}) } - end end end end diff --git a/spec/classes/cube_spec.rb b/spec/classes/cube_spec.rb index 4538a9b3..b66cf4f0 100644 --- a/spec/classes/cube_spec.rb +++ b/spec/classes/cube_spec.rb @@ -3,7 +3,7 @@ describe('icingaweb2::module::cube', type: :class) do let(:pre_condition) do [ - "class { 'icingaweb2': }", + "class { 'icingaweb2': db_type => 'mysql', db_password => 'secret' }", ] end diff --git a/spec/classes/director_service_spec.rb b/spec/classes/director_service_spec.rb index c69791c6..0a6f1107 100644 --- a/spec/classes/director_service_spec.rb +++ b/spec/classes/director_service_spec.rb @@ -3,7 +3,7 @@ describe('icingaweb2::module::director::service', type: :class) do let(:pre_condition) do [ - "class { 'icingaweb2': }", + "class { 'icingaweb2': db_type => 'mysql', db_password => 'secret' }", "class { 'icingaweb2::module::director': }", ] end diff --git a/spec/classes/director_spec.rb b/spec/classes/director_spec.rb index 8427a0d8..8b51aa28 100644 --- a/spec/classes/director_spec.rb +++ b/spec/classes/director_spec.rb @@ -3,7 +3,7 @@ describe('icingaweb2::module::director', type: :class) do let(:pre_condition) do [ - "class { 'icingaweb2': }", + "class { 'icingaweb2': db_type => 'mysql', db_password => 'secret' }", ] end diff --git a/spec/classes/doc_spec.rb b/spec/classes/doc_spec.rb index d8f1a414..e6bf3c2c 100644 --- a/spec/classes/doc_spec.rb +++ b/spec/classes/doc_spec.rb @@ -3,7 +3,7 @@ describe('icingaweb2::module::doc', type: :class) do let(:pre_condition) do [ - "class { 'icingaweb2': }", + "class { 'icingaweb2': db_type => 'mysql', db_password => 'secret' }", ] end diff --git a/spec/classes/elasticsearch_spec.rb b/spec/classes/elasticsearch_spec.rb index 9c5ec102..97cd95ec 100644 --- a/spec/classes/elasticsearch_spec.rb +++ b/spec/classes/elasticsearch_spec.rb @@ -3,7 +3,7 @@ describe('icingaweb2::module::elasticsearch', type: :class) do let(:pre_condition) do [ - "class { 'icingaweb2': }", + "class { 'icingaweb2': db_type => 'mysql', db_password => 'secret' }", ] end diff --git a/spec/classes/fileshipper_spec.rb b/spec/classes/fileshipper_spec.rb index 55d1677e..0861f893 100644 --- a/spec/classes/fileshipper_spec.rb +++ b/spec/classes/fileshipper_spec.rb @@ -3,7 +3,7 @@ describe('icingaweb2::module::fileshipper', type: :class) do let(:pre_condition) do [ - "class { 'icingaweb2': }", + "class { 'icingaweb2': db_type => 'mysql', db_password => 'secret' }", ] end diff --git a/spec/classes/generictts_spec.rb b/spec/classes/generictts_spec.rb index 4dd0c9ca..899801b6 100644 --- a/spec/classes/generictts_spec.rb +++ b/spec/classes/generictts_spec.rb @@ -3,7 +3,7 @@ describe('icingaweb2::module::generictts', type: :class) do let(:pre_condition) do [ - "class { 'icingaweb2': }", + "class { 'icingaweb2': db_type => 'mysql', db_password => 'secret' }", ] end diff --git a/spec/classes/graphite_spec.rb b/spec/classes/graphite_spec.rb index 242e751d..97665b9a 100644 --- a/spec/classes/graphite_spec.rb +++ b/spec/classes/graphite_spec.rb @@ -3,7 +3,7 @@ describe('icingaweb2::module::graphite', type: :class) do let(:pre_condition) do [ - "class { 'icingaweb2': }", + "class { 'icingaweb2': db_type => 'mysql', db_password => 'secret' }", ] end diff --git a/spec/classes/icingadb_spec.rb b/spec/classes/icingadb_spec.rb index 5610e1cd..132761a7 100644 --- a/spec/classes/icingadb_spec.rb +++ b/spec/classes/icingadb_spec.rb @@ -3,7 +3,7 @@ describe('icingaweb2::module::icingadb', type: :class) do let(:pre_condition) do [ - "class { 'icingaweb2': }", + "class { 'icingaweb2': db_type => 'mysql', db_password => 'secret' }", ] end diff --git a/spec/classes/icingaweb2_spec.rb b/spec/classes/icingaweb2_spec.rb index c491fa29..2cfae955 100644 --- a/spec/classes/icingaweb2_spec.rb +++ b/spec/classes/icingaweb2_spec.rb @@ -8,6 +8,13 @@ end context 'with defaults' do + let(:params) do + { + db_type: 'mysql', + db_password: 'secret', + } + end + it { is_expected.to compile } it { is_expected.to contain_class('icingaweb2::config') } it { is_expected.to contain_class('icingaweb2::install') } @@ -16,7 +23,11 @@ context 'with manage_package => false' do let(:params) do - { manage_package: false } + { + manage_package: false, + db_type: 'mysql', + db_password: 'secret', + } end it { is_expected.not_to contain_package('icinga2').with('ensure' => 'installed') } @@ -25,6 +36,8 @@ context 'with additional resources, user and group backend' do let(:params) do { + db_type: 'mysql', + db_password: 'secret', resources: { foo: { type: 'ldap' }, baz: { type: 'pgsql', host: 'localhost', database: 'baz', port: 5432 }, diff --git a/spec/classes/monitoring_spec.rb b/spec/classes/monitoring_spec.rb index 2e08477c..995ef909 100644 --- a/spec/classes/monitoring_spec.rb +++ b/spec/classes/monitoring_spec.rb @@ -3,7 +3,7 @@ describe('icingaweb2::module::monitoring', type: :class) do let(:pre_condition) do [ - "class { 'icingaweb2': }", + "class { 'icingaweb2': db_type => 'mysql', db_password => 'secret' }", ] end diff --git a/spec/classes/puppetdb_spec.rb b/spec/classes/puppetdb_spec.rb index c2fec99f..96827a89 100644 --- a/spec/classes/puppetdb_spec.rb +++ b/spec/classes/puppetdb_spec.rb @@ -3,7 +3,7 @@ describe('icingaweb2::module::puppetdb', type: :class) do let(:pre_condition) do [ - "class { 'icingaweb2': }", + "class { 'icingaweb2': db_type => 'mysql', db_password => 'secret' }", ] end diff --git a/spec/classes/translation_spec.rb b/spec/classes/translation_spec.rb index bb39ab20..2938da5e 100644 --- a/spec/classes/translation_spec.rb +++ b/spec/classes/translation_spec.rb @@ -3,7 +3,7 @@ describe('icingaweb2::module::translation', type: :class) do let(:pre_condition) do [ - "class { 'icingaweb2': }", + "class { 'icingaweb2': db_type => 'mysql', db_password => 'secret' }", ] end diff --git a/spec/classes/vsphere_spec.rb b/spec/classes/vsphere_spec.rb index e8cd7e37..e84127ac 100644 --- a/spec/classes/vsphere_spec.rb +++ b/spec/classes/vsphere_spec.rb @@ -3,7 +3,7 @@ describe('icingaweb2::module::vsphere', type: :class) do let(:pre_condition) do [ - "class { 'icingaweb2': }", + "class { 'icingaweb2': db_type => 'mysql', db_password => 'secret' }", ] end diff --git a/spec/classes/vspheredb_service_spec.rb b/spec/classes/vspheredb_service_spec.rb index 05193e8e..63dbf530 100644 --- a/spec/classes/vspheredb_service_spec.rb +++ b/spec/classes/vspheredb_service_spec.rb @@ -3,7 +3,7 @@ describe('icingaweb2::module::vspheredb::service', type: :class) do let(:pre_condition) do [ - "class { 'icingaweb2': }", + "class { 'icingaweb2': db_type => 'mysql', db_password => 'secret' }", "class { 'icingaweb2::module::vspheredb': }", ] end diff --git a/spec/classes/vspheredb_spec.rb b/spec/classes/vspheredb_spec.rb index 5a3d2e5d..d376091d 100644 --- a/spec/classes/vspheredb_spec.rb +++ b/spec/classes/vspheredb_spec.rb @@ -3,7 +3,7 @@ describe('icingaweb2::module::vspheredb', type: :class) do let(:pre_condition) do [ - "class { 'icingaweb2': }", + "class { 'icingaweb2': db_type => 'mysql', db_password => 'secret' }", ] end diff --git a/spec/defines/authmethod_spec.rb b/spec/defines/authmethod_spec.rb index be116b97..ee9388f6 100644 --- a/spec/defines/authmethod_spec.rb +++ b/spec/defines/authmethod_spec.rb @@ -4,7 +4,7 @@ let(:title) { 'myauthmethod' } let(:pre_condition) do [ - "class { 'icingaweb2': }", + "class { 'icingaweb2': db_type => 'mysql', db_password => 'secret' }", ] end diff --git a/spec/defines/groupbackend_spec.rb b/spec/defines/groupbackend_spec.rb index 83dddc46..c0063c21 100644 --- a/spec/defines/groupbackend_spec.rb +++ b/spec/defines/groupbackend_spec.rb @@ -4,7 +4,7 @@ let(:title) { 'mygroupbackend' } let(:pre_condition) do [ - "class { 'icingaweb2': }", + "class { 'icingaweb2': db_type => 'mysql', db_password => 'secret' }", ] end diff --git a/spec/defines/inisection_spec.rb b/spec/defines/inisection_spec.rb index eca7d460..4fba6a68 100644 --- a/spec/defines/inisection_spec.rb +++ b/spec/defines/inisection_spec.rb @@ -4,7 +4,7 @@ let(:title) { 'foo' } let(:pre_condition) do [ - "class { 'icingaweb2': }", + "class { 'icingaweb2': db_type => 'mysql', db_password => 'secret' }", ] end diff --git a/spec/defines/module_spec.rb b/spec/defines/module_spec.rb index 5d44e13f..78a7b91f 100644 --- a/spec/defines/module_spec.rb +++ b/spec/defines/module_spec.rb @@ -4,7 +4,7 @@ let(:title) { 'mymodule' } let(:pre_condition) do [ - "class { 'icingaweb2': }", + "class { 'icingaweb2': db_type => 'mysql', db_password => 'secret' }", ] end diff --git a/spec/defines/navigation_spec.rb b/spec/defines/navigation_spec.rb index a98e6253..bf4975bc 100644 --- a/spec/defines/navigation_spec.rb +++ b/spec/defines/navigation_spec.rb @@ -4,7 +4,7 @@ let(:title) { 'myitem' } let(:pre_condition) do [ - "class { 'icingaweb2': }", + "class { 'icingaweb2': db_type => 'mysql', db_password => 'secret' }", ] end diff --git a/spec/defines/resource_database_spec.rb b/spec/defines/resource_database_spec.rb index f55d2f23..4068d8a0 100644 --- a/spec/defines/resource_database_spec.rb +++ b/spec/defines/resource_database_spec.rb @@ -4,7 +4,7 @@ let(:title) { 'myresource' } let(:pre_condition) do [ - "class { 'icingaweb2': }", + "class { 'icingaweb2': db_type => 'mysql', db_password => 'secret' }", ] end diff --git a/spec/defines/resource_ldap_spec.rb b/spec/defines/resource_ldap_spec.rb index a063095f..ac045a97 100644 --- a/spec/defines/resource_ldap_spec.rb +++ b/spec/defines/resource_ldap_spec.rb @@ -4,7 +4,7 @@ let(:title) { 'myresource' } let(:pre_condition) do [ - "class { 'icingaweb2': }", + "class { 'icingaweb2': db_type => 'mysql', db_password => 'secret' }", ] end diff --git a/spec/defines/role_spec.rb b/spec/defines/role_spec.rb index dec0acdb..d8c463cb 100644 --- a/spec/defines/role_spec.rb +++ b/spec/defines/role_spec.rb @@ -4,7 +4,7 @@ let(:title) { 'myrole' } let(:pre_condition) do [ - "class { 'icingaweb2': }", + "class { 'icingaweb2': db_type => 'mysql', db_password => 'secret' }", ] end