Skip to content

Commit

Permalink
Merge pull request #146 from yakatz/bug/too_many_files
Browse files Browse the repository at this point in the history
Add option to manage imgcache directory
  • Loading branch information
kenyon committed Sep 3, 2023
2 parents 2b414f9 + c944f20 commit 322bef3
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 1 deletion.
9 changes: 9 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ The following parameters are available in the `smokeping` class:
* [`manage_apache`](#-smokeping--manage_apache)
* [`manage_firewall`](#-smokeping--manage_firewall)
* [`manage_selinux`](#-smokeping--manage_selinux)
* [`manage_imgcache`](#-smokeping--manage_imgcache)
* [`package_perldoc`](#-smokeping--package_perldoc)
* [`syslogpriority`](#-smokeping--syslogpriority)
* [`default_slaves`](#-smokeping--default_slaves)
Expand Down Expand Up @@ -393,6 +394,14 @@ Should we load an SELinux policy to allow Smokeping to work on Red Hat distros?

Default value: `false`

##### <a name="-smokeping--manage_imgcache"></a>`manage_imgcache`

Data type: `Boolean`

Should we manage the permissions on the imgcache directory?

Default value: `true`

##### <a name="-smokeping--package_perldoc"></a>`package_perldoc`

Data type: `String[1]`
Expand Down
4 changes: 4 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
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 @@ -175,6 +178,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
2 changes: 1 addition & 1 deletion manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
recurse => true,
}

if $smokeping::mode =~ /(master|standalone)/ {
if $smokeping::mode =~ /(master|standalone)/ and $smokeping::manage_imgcache {
file { $smokeping::path_imgcache:
ensure => directory,
owner => $smokeping::webserver_user,
Expand Down
51 changes: 51 additions & 0 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,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

context 'slave mode' do
Expand Down

0 comments on commit 322bef3

Please sign in to comment.