From d0987d0d623e6b02a5abfdc73923427ba6016e0d Mon Sep 17 00:00:00 2001 From: Yehuda Katz Date: Sun, 16 Jan 2022 15:59:32 -0500 Subject: [PATCH] Don't manage imgcache dir Possible workaround for #145 --- manifests/init.pp | 4 ++++ manifests/install.pp | 14 +++++++----- spec/classes/init_spec.rb | 48 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 6 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 9ee06dd..ab63ebe 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -122,6 +122,9 @@ # # @param manage_selinux # Should we load an SELinux policy to allow Smokeping to work on Red Hat distros? +# +# @param manage_imgcache +# Should we manage the permissions on the imgcache directory? class smokeping ( Stdlib::HTTPUrl $cgiurl, Stdlib::HTTPUrl $master_url, @@ -174,6 +177,7 @@ Boolean $manage_apache = false, Boolean $manage_firewall = false, Boolean $manage_selinux = false, + Boolean $manage_imgcache = true, Stdlib::Fqdn $servername = $facts['networking']['fqdn'], ) { if $manage_apache { diff --git a/manifests/install.pp b/manifests/install.pp index dff3aad..05df8c0 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -28,11 +28,13 @@ require => Package['smokeping'], recurse => true, } - file { $smokeping::path_imgcache: - ensure => directory, - owner => $smokeping::webserver_user, - group => $smokeping::webserver_group, - require => Package['smokeping'], - recurse => true, + if $smokeping::manage_imgcache { + file { $smokeping::path_imgcache: + ensure => directory, + owner => $smokeping::webserver_user, + group => $smokeping::webserver_group, + require => Package['smokeping'], + recurse => true, + } } } diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index e2a9796..e6ba241 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -24,7 +24,55 @@ it { is_expected.to contain_class('smokeping::install') } it { is_expected.to contain_class('smokeping::service') } it { is_expected.to contain_class('smokeping::config') } + + case facts[:osfamily] + when 'RedHat' + it { is_expected.to contain_file('/var/lib/smokeping/images').with( + ensure: 'directory', + owner: 'apache', + group: 'apache', + recurse: true, + ) } + when 'Debian' + it { is_expected.to contain_file('/var/cache/smokeping/images').with( + ensure: 'directory', + owner: 'www-data', + group: 'www-data', + recurse: true, + ) } + end end + + context "change img_cachedir" do + + let :params do + { + cgiurl: 'http://some.url/smokeping.cgi', + master_url: 'http://somewhere/cgi-bin/smokeping.cgi', + path_imgcache: '/smokeping/images', + } + end + + it { is_expected.to contain_file('/smokeping/images').with( + ensure: 'directory', + recurse: true, + ) } + + context "don't manage img_cachedir" do + + let :params do + { + cgiurl: 'http://some.url/smokeping.cgi', + master_url: 'http://somewhere/cgi-bin/smokeping.cgi', + path_imgcache: '/smokeping/images', + manage_imgcache: false, + } + end + + it { is_expected.not_to contain_file('/smokeping/images') } + end + end + end end end