Skip to content

Commit be6f385

Browse files
committed
(maint) Add support for mod_watchdog
This apache module defines programmatic hooks for other apache modules to periodically run tasks. It is a dependency for some apache modules not yet supported by the puppet module: * mod_heartbeat * mod_heartmonitor * mod_md * mod_proxy_hcheck
1 parent c3fc5a7 commit be6f385

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed

manifests/mod/watchdog.pp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# @summary
2+
# Installs and configures `mod_watchdog`.
3+
#
4+
# @param watchdog_interval
5+
# Sets the interval at which the watchdog_step hook runs.
6+
#
7+
# @see https://httpd.apache.org/docs/current/mod/mod_watchdog.html for additional documentation.
8+
class apache::mod::watchdog (
9+
Optional[Integer] $watchdog_interval = undef,
10+
) {
11+
include apache
12+
13+
$module_builtin = $facts['os']['family'] in ['Debian']
14+
15+
unless $module_builtin {
16+
apache::mod { 'watchdog':
17+
}
18+
}
19+
20+
if $watchdog_interval {
21+
file { 'watchdog.conf':
22+
ensure => file,
23+
path => "${apache::mod_dir}/watchdog.conf",
24+
mode => $apache::file_mode,
25+
content => "WatchdogInterval ${watchdog_interval}\n",
26+
require => Exec["mkdir ${apache::mod_dir}"],
27+
before => File[$apache::mod_dir],
28+
notify => Class['apache::service'],
29+
}
30+
}
31+
}

spec/classes/mod/watchdog_spec.rb

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
require 'spec_helper'
2+
3+
describe 'apache::mod::watchdog', type: :class do
4+
it_behaves_like 'a mod class, without including apache'
5+
6+
on_supported_os.each do |os, os_facts|
7+
context "On #{os}" do
8+
let :facts do
9+
os_facts
10+
end
11+
12+
if os_facts[:os]['family'] == 'Debian'
13+
it { is_expected.not_to contain_apache__mod('watchdog') }
14+
else
15+
it { is_expected.to contain_apache__mod('watchdog') }
16+
end
17+
18+
context 'with default configuration' do
19+
it { is_expected.not_to contain_file('watchdog.conf') }
20+
end
21+
22+
context 'with custom configuration' do
23+
let(:params) do
24+
{
25+
watchdog_interval: 5,
26+
}
27+
end
28+
29+
it { is_expected.to contain_file('watchdog.conf').with_content(%r{^WatchdogInterval 5$}) }
30+
end
31+
end
32+
end
33+
end

0 commit comments

Comments
 (0)