From 0f6948c8ca29efbb72a4dffc51b7e07c5b79c13b Mon Sep 17 00:00:00 2001 From: Lennart Betz Date: Mon, 13 Jan 2020 08:11:18 +0100 Subject: [PATCH] fix owner and groupship of dbconfig files on debian, extend unit tests --- manifests/feature/idomysql.pp | 4 +++- manifests/feature/idopgsql.pp | 4 +++- spec/classes/idomysql_spec.rb | 9 +++++++++ spec/classes/idopgsql_spec.rb | 9 +++++++++ 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/manifests/feature/idomysql.pp b/manifests/feature/idomysql.pp index 5f4a1a180..28703604a 100644 --- a/manifests/feature/idomysql.pp +++ b/manifests/feature/idomysql.pp @@ -297,10 +297,12 @@ # install additional package if $ido_mysql_package_name and $manage_package { if $::osfamily == 'debian' { - ensure_resources('file', { '/etc/dbconfig-common' => { ensure => directory } }) + ensure_resources('file', { '/etc/dbconfig-common' => { ensure => directory, owner => 'root', group => 'root' } }) file { "/etc/dbconfig-common/${ido_mysql_package_name}.conf": ensure => file, content => "dbc_install='false'\ndbc_upgrade='false'\ndbc_remove='false'\n", + owner => 'root', + group => 'root', mode => '0600', before => Package[$ido_mysql_package_name], } diff --git a/manifests/feature/idopgsql.pp b/manifests/feature/idopgsql.pp index 5dd6ea2a9..0064b14b9 100644 --- a/manifests/feature/idopgsql.pp +++ b/manifests/feature/idopgsql.pp @@ -119,10 +119,12 @@ # install additional package if $ido_pgsql_package_name and $manage_package { if $::osfamily == 'debian' { - ensure_resources('file', { '/etc/dbconfig-common' => { ensure => directory } }) + ensure_resources('file', { '/etc/dbconfig-common' => { ensure => directory, owner => 'root', group => 'root' } }) file { "/etc/dbconfig-common/${ido_pgsql_package_name}.conf": ensure => file, content => "dbc_install='false'\ndbc_upgrade='false'\ndbc_remove='false'\n", + owner => 'root', + group => 'root', mode => '0600', before => Package[$ido_pgsql_package_name], } diff --git a/spec/classes/idomysql_spec.rb b/spec/classes/idomysql_spec.rb index e773770c2..f6242bb1a 100644 --- a/spec/classes/idomysql_spec.rb +++ b/spec/classes/idomysql_spec.rb @@ -69,6 +69,15 @@ it { is_expected.to contain_package('icinga2-ido-mysql').with({ 'ensure' => 'installed' }) } end + if facts[:osfamily] == 'Debian' + it { is_expected.to contain_file('/etc/dbconfig-common/icinga2-ido-mysql.conf') + .with({ + 'ensure' => 'file', + 'owner' => 'root', + 'group' => 'root', }) + } + end + it { is_expected.to contain_icinga2__feature('ido-mysql').with({'ensure' => 'present'}) } it { is_expected.to contain_icinga2__object('icinga2::object::IdoMysqlConnection::ido-mysql') diff --git a/spec/classes/idopgsql_spec.rb b/spec/classes/idopgsql_spec.rb index c69f0474e..7f5c6339a 100644 --- a/spec/classes/idopgsql_spec.rb +++ b/spec/classes/idopgsql_spec.rb @@ -56,6 +56,15 @@ it { is_expected.to contain_package('icinga2-ido-pgsql').with({ 'ensure' => 'installed' }) } end + if facts[:osfamily] == 'Debian' + it { is_expected.to contain_file('/etc/dbconfig-common/icinga2-ido-pgsql.conf') + .with({ + 'ensure' => 'file', + 'owner' => 'root', + 'group' => 'root', }) + } + end + it { is_expected.to contain_icinga2__feature('ido-pgsql').with({'ensure' => 'present'}) } it { is_expected.to contain_concat__fragment('icinga2::object::IdoPgsqlConnection::ido-pgsql')