Skip to content

Commit

Permalink
Remove config backend, only db is supported now
Browse files Browse the repository at this point in the history
  • Loading branch information
lbetz committed Oct 18, 2023
1 parent 4bd4c05 commit 71dcdbf
Show file tree
Hide file tree
Showing 31 changed files with 80 additions and 121 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
}
Expand Down
14 changes: 1 addition & 13 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -374,12 +373,10 @@ Default value: `'icingaweb2'`

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

Data type: `Optional[Icingaweb2::Secret]`
Data type: `Icingaweb2::Secret`

Password for database access.

Default value: `undef`

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

Data type: `Optional[Boolean]`
Expand Down Expand Up @@ -462,15 +459,6 @@ Cipher to use for the encrypted database connection.

Default value: `undef`

##### <a name="-icingaweb2--config_backend"></a>`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'`

##### <a name="-icingaweb2--conf_user"></a>`conf_user`

Data type: `String`
Expand Down
59 changes: 26 additions & 33 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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,
}

Expand Down Expand Up @@ -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 {
Expand Down
7 changes: 1 addition & 6 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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 = {},
Expand Down
2 changes: 1 addition & 1 deletion spec/classes/audit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion spec/classes/businessprocess_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
55 changes: 13 additions & 42 deletions spec/classes/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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') }
Expand All @@ -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') }
Expand All @@ -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') }
Expand All @@ -58,63 +60,32 @@
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 {
is_expected.to contain_icingaweb2__inisection('config-cookie')
.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
2 changes: 1 addition & 1 deletion spec/classes/cube_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion spec/classes/director_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/classes/director_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion spec/classes/doc_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion spec/classes/elasticsearch_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion spec/classes/fileshipper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion spec/classes/generictts_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion spec/classes/graphite_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion spec/classes/icingadb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading

0 comments on commit 71dcdbf

Please sign in to comment.