Skip to content

Commit

Permalink
Don't manage imgcache dir
Browse files Browse the repository at this point in the history
Possible workaround for voxpupuli#145
  • Loading branch information
yakatz committed Jan 17, 2022
1 parent 3edef1a commit c152dca
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 6 deletions.
4 changes: 4 additions & 0 deletions manifests/init.pp
Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down
14 changes: 8 additions & 6 deletions manifests/install.pp
Expand Up @@ -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,
}
}
}
51 changes: 51 additions & 0 deletions spec/classes/init_spec.rb
Expand Up @@ -24,6 +24,57 @@
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
Expand Down

0 comments on commit c152dca

Please sign in to comment.