From 38f173a70652594d12c6a4f7eac8a6deeb5e86e9 Mon Sep 17 00:00:00 2001 From: Lennart Betz Date: Tue, 12 Feb 2019 13:54:42 +0100 Subject: [PATCH] fix #526 Set default of host to localhost for feature idopgsql --- README.md | 5 +++-- data/Windows-kernel.yaml | 2 +- examples/init_idopgsql.pp | 1 - manifests/feature/idopgsql.pp | 4 ++-- spec/classes/idopgsql_spec.rb | 14 +++++++++----- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 4a1e29242..a5a7e2016 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,7 @@ configuration of Icinga 2 on multiple operating systems. * Parameter ssl_crl_path was renamed to ssl_crl. * Feature `idopgsql` * Parameter `password` is required now. + * Parameter default for `host` is set to `localhost` * Feature `idomysql` * Parameter `password` is required now. * Parameter default for `host` is set to `localhost` @@ -1426,10 +1427,10 @@ Enables or disables the `ido-pgsql` feature. Either `present` or `absent`. Defines if the feature `ido-pgsql` should be enabled. Defaults to `present`. ##### `host` -PostgreSQL database host address. Icinga defaults to `localhost`. +PostgreSQL database host address. Defaults to `localhost`. ##### `port` -PostgreSQL database port. Icinga defaults to `3306`. +PostgreSQL database port. Defaults to `5432`. ##### `user` PostgreSQL database user with read/write permission to the icinga database. Icinga defaults to `icinga`. diff --git a/data/Windows-kernel.yaml b/data/Windows-kernel.yaml index 0fe2dc97f..b0371f78f 100644 --- a/data/Windows-kernel.yaml +++ b/data/Windows-kernel.yaml @@ -7,7 +7,7 @@ icinga2::globals::group: null icinga2::globals::ido_mysql_package_name: null icinga2::globals::ido_mysql_schema: C:/Program Files/icinga2/usr/share/icinga2-ido-mysql/schema/mysql.sql icinga2::globals::ido_pgsql_package_name: null -icinga2::globals::ido_pgsql_schema: C:/Program Files/icinga2/usr/share/icinga2-ido-mysql/schema/pgsql.sql +icinga2::globals::ido_pgsql_schema: C:/Program Files/icinga2/usr/share/icinga2-ido-pgsql/schema/pgsql.sql icinga2::globals::icinga2_bin: C:/Program Files/icinga2/sbin/icinga2.exe icinga2::globals::conf_dir: C:/ProgramData/icinga2/etc/icinga2 icinga2::globals::lib_dir: C:/Program Files/icinga2/usr/lib diff --git a/examples/init_idopgsql.pp b/examples/init_idopgsql.pp index 7dba5f5ca..687f5deeb 100644 --- a/examples/init_idopgsql.pp +++ b/examples/init_idopgsql.pp @@ -10,7 +10,6 @@ } class{ 'icinga2::feature::idopgsql': - host => '127.0.0.1', user => "icinga2", password => "supersecret", database => "icinga2", diff --git a/manifests/feature/idopgsql.pp b/manifests/feature/idopgsql.pp index e19b4e2ff..247a38385 100644 --- a/manifests/feature/idopgsql.pp +++ b/manifests/feature/idopgsql.pp @@ -8,7 +8,7 @@ # Set to present enables the feature ido-pgsql, absent disables it. Defaults to present. # # [*host*] -# PostgreSQL database host address. Defaults to '127.0.0.1'. +# PostgreSQL database host address. Defaults to 'localhost'. # # [*port*] # PostgreSQL database port. Defaults to '5432'. @@ -74,7 +74,7 @@ class icinga2::feature::idopgsql( String $password, Enum['absent', 'present'] $ensure = present, - Stdlib::Host $host = '127.0.0.1', + Stdlib::Host $host = 'localhost', Stdlib::Port::Unprivileged $port = 5432, String $user = 'icinga', String $database = 'icinga', diff --git a/spec/classes/idopgsql_spec.rb b/spec/classes/idopgsql_spec.rb index a5ab1b8d7..cfae49898 100644 --- a/spec/classes/idopgsql_spec.rb +++ b/spec/classes/idopgsql_spec.rb @@ -18,21 +18,21 @@ when 'windows' @icinga2_conf_dir = 'C:/ProgramData/icinga2/etc/icinga2' @icinga2_pki_dir = 'C:/ProgramData/icinga2/var/lib/icinga2/certs' - @ido_mysql_schema_dir = 'C:/Program Files/icinga2/usr/share/icinga2-ido-mysql/schema' + @ido_pgsql_schema_dir = 'C:/Program Files/icinga2/usr/share/icinga2-ido-pgsql/schema' @icinga2_sslkey_mode = nil @icinga2_user = nil @icinga2_group = nil when 'FreeBSD' @icinga2_conf_dir = '/usr/local/etc/icinga2' @icinga2_pki_dir = '/var/lib/icinga2/certs' - @ido_mysql_schema_dir = '/usr/local/share/icinga2-ido-mysql/schema' + @ido_pgsql_schema_dir = '/usr/local/share/icinga2-ido-pgsql/schema' @icinga2_sslkey_mode = '0600' @icinga2_user = 'icinga' @icinga2_group = 'icinga' else @icinga2_conf_dir = '/etc/icinga2' @icinga2_pki_dir = '/var/lib/icinga2/certs' - @ido_mysql_schema_dir = '/usr/share/icinga2-ido-mysql/schema' + @ido_pgsql_schema_dir = '/usr/share/icinga2-ido-pgsql/schema' @icinga2_sslkey_mode = '0600' case facts[:osfamily] when 'Debian' @@ -81,11 +81,15 @@ } end - it { is_expected.to contain_exec('idopgsql-import-schema') } + it { is_expected.to contain_exec('idopgsql-import-schema') + .with({ + 'user' => 'root', + 'environment' => ["PGPASSWORD=foo"], + 'command' => "psql -h 'localhost' -U 'icinga' -p '5432' -d 'icinga' -w -f #{@ido_pgsql_schema_dir}/pgsql.sql" }) } end if facts[:kernel] == 'Linux' - context "with icinga2::manage_package => false" do + context "with manage_package => false" do let(:params) do { :password => 'foo'