diff --git a/CHANGELOG.md b/CHANGELOG.md index 1048a11..1df5c35 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,176 +1,165 @@ -## 2020-12-09 - Release 3.0.0 -### Summary +# Changelog -This release adds the support for Debian 10/Buster and for CentOS 8 and the ability to use special characters in `httpd_password` parameter. -It fixes logging limitations and Amazon Linux compatibility. -It uses a Docker Compose file to use PDK 1.8.1. +All notable changes to this project will be documented in this file. +Each new release typically also includes the latest modulesync defaults. +These should not affect the functionality of the module. -***BREAKING CHANGES*** -This release remove the support for Puppet 3. +## [v3.0.0](https://github.com/voxpupuli/puppet-monit/tree/v3.0.0) (2024-08-15) -#### Features -- Added the support for Debian 10/Buster -- Added the support for CentOS 8 -- Added ability to use special characters in `httpd_password` parameter +[Full Changelog](https://github.com/voxpupuli/puppet-monit/compare/v3.0.0...v3.0.0) -#### BugFixes -- Fixed logging limitations -- Fixed Amazon Linux compatibility +**Breaking changes:** -#### Development -- Added a Docker Compose file to use PDK +- Drop Ubuntu 18.04 support [\#54](https://github.com/voxpupuli/puppet-monit/pull/54) ([zilchms](https://github.com/zilchms)) +- Drop support for puppetlabs-firewall \<5.0.0 [\#51](https://github.com/voxpupuli/puppet-monit/pull/51) ([zilchms](https://github.com/zilchms)) +- Clean up fixtures and codebase hardening [\#48](https://github.com/voxpupuli/puppet-monit/pull/48) ([zilchms](https://github.com/zilchms)) +- Drop Oracle Linux 7 support [\#47](https://github.com/voxpupuli/puppet-monit/pull/47) ([zilchms](https://github.com/zilchms)) +- Drop Debian 10 support [\#45](https://github.com/voxpupuli/puppet-monit/pull/45) ([zilchms](https://github.com/zilchms)) +- Drop amazon 2016 and 2018; add amazon 2023 [\#42](https://github.com/voxpupuli/puppet-monit/pull/42) ([zilchms](https://github.com/zilchms)) +- Drop ScientificLinux 5 and 6 support [\#41](https://github.com/voxpupuli/puppet-monit/pull/41) ([zilchms](https://github.com/zilchms)) +- drop CentOs 5 and 6 support [\#40](https://github.com/voxpupuli/puppet-monit/pull/40) ([zilchms](https://github.com/zilchms)) +- Drop OracleLinux 5 and 6 support [\#39](https://github.com/voxpupuli/puppet-monit/pull/39) ([zilchms](https://github.com/zilchms)) +- Drop Redhat 5 and 6 support [\#38](https://github.com/voxpupuli/puppet-monit/pull/38) ([zilchms](https://github.com/zilchms)) +- drop EOL Ubuntu 10, 12, 14 and 16 support [\#37](https://github.com/voxpupuli/puppet-monit/pull/37) ([zilchms](https://github.com/zilchms)) +- drop EOL Debian 6, 7, 8, 9 support [\#36](https://github.com/voxpupuli/puppet-monit/pull/36) ([zilchms](https://github.com/zilchms)) +- Drop Puppet 6 support [\#27](https://github.com/voxpupuli/puppet-monit/pull/27) ([bastelfreak](https://github.com/bastelfreak)) -## 2018-11-23 - Release 2.0.1 -### Summary +**Implemented enhancements:** -This release fixes the support for Amazon Linux 2 and uses PDK 1.7.1. +- focal support needs to be added to fail check [\#20](https://github.com/voxpupuli/puppet-monit/issues/20) +- Add RedHat/CentOS/Rocky/Alma 8 and 9 support [\#55](https://github.com/voxpupuli/puppet-monit/pull/55) ([zilchms](https://github.com/zilchms)) +- Add Ubuntu 20.04 and 22.04 support [\#53](https://github.com/voxpupuli/puppet-monit/pull/53) ([zilchms](https://github.com/zilchms)) +- Add Debian 12 support [\#52](https://github.com/voxpupuli/puppet-monit/pull/52) ([zilchms](https://github.com/zilchms)) +- puppetlabs/firewall: Allow 8.x [\#50](https://github.com/voxpupuli/puppet-monit/pull/50) ([zilchms](https://github.com/zilchms)) +- Add Oracle Linux 8 and 9 support [\#46](https://github.com/voxpupuli/puppet-monit/pull/46) ([zilchms](https://github.com/zilchms)) +- Add Debian 11 support [\#44](https://github.com/voxpupuli/puppet-monit/pull/44) ([zilchms](https://github.com/zilchms)) +- Add Puppet 8 support [\#29](https://github.com/voxpupuli/puppet-monit/pull/29) ([bastelfreak](https://github.com/bastelfreak)) +- puppetlabs/stdlib: Allow 9.x [\#28](https://github.com/voxpupuli/puppet-monit/pull/28) ([bastelfreak](https://github.com/bastelfreak)) +- fixing Amazon Linux 2 support [\#23](https://github.com/voxpupuli/puppet-monit/pull/23) ([erik-frontify](https://github.com/erik-frontify)) -#### BugFixes -- Fixed the support for Amazon Linux 2 +**Closed issues:** -## 2018-10-07 - Release 2.0.0 -### Summary +- Support latest puppet version \(7.x\) [\#26](https://github.com/voxpupuli/puppet-monit/issues/26) +- Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Function Call, monit supports Amazon Linux 2. Detected operatingsystemmajrelease is \<2\>. [\#21](https://github.com/voxpupuli/puppet-monit/issues/21) +- Support for CentOS 8 [\#16](https://github.com/voxpupuli/puppet-monit/issues/16) +- Spec test for v2.0.1 are failing [\#13](https://github.com/voxpupuli/puppet-monit/issues/13) +- old syntax detected [\#11](https://github.com/voxpupuli/puppet-monit/issues/11) -This release adds `httpd_allow` configuration and support for MMonit HTTPs addresses and uses PDK 1.7.0. +**Merged pull requests:** -***BREAKING CHANGES*** -The MMonit address is now by default with HTTPs with the port 8443 (8080 previously). +- remove specialcasing for no longer supported OS [\#43](https://github.com/voxpupuli/puppet-monit/pull/43) ([zilchms](https://github.com/zilchms)) -#### Features -- Add `httpd_allow` configuration -- Add support for MMonit HTTPs addresses +## [v3.0.0](https://github.com/voxpupuli/puppet-monit/tree/v3.0.0) (2020-12-09) -## 2018-07-09 - Release 1.4.0 -### Summary +[Full Changelog](https://github.com/voxpupuli/puppet-monit/compare/v2.0.1...v3.0.0) -This release adds support to Amazon Linux 2 and uses PDK 1.6.1. +**Merged pull requests:** -#### Features -- Added support to Amazon Linux 2 +- PDK update to 1.18 [\#19](https://github.com/voxpupuli/puppet-monit/pull/19) ([aursu](https://github.com/aursu)) +- Added ability to use special characters in httpd\_password parameter [\#18](https://github.com/voxpupuli/puppet-monit/pull/18) ([aursu](https://github.com/aursu)) +- Fixing logging limitations with syslog. [\#15](https://github.com/voxpupuli/puppet-monit/pull/15) ([amigne](https://github.com/amigne)) +- add Support for debian 10/buster [\#10](https://github.com/voxpupuli/puppet-monit/pull/10) ([to-kn](https://github.com/to-kn)) -## 2018-05-03 - Release 1.3.0 -### Summary +## [v2.0.1](https://github.com/voxpupuli/puppet-monit/tree/v2.0.1) (2018-11-23) -This release adds support to Ubuntu Bionic and uses PDK 1.5.0. +[Full Changelog](https://github.com/voxpupuli/puppet-monit/compare/v2.0.0...v2.0.1) -#### Features -- Added support to Ubuntu Bionic +**Implemented enhancements:** -## 2018-01-26 - Release 1.2.0 -### Summary +- Add httpd\_allow configuration [\#5](https://github.com/voxpupuli/puppet-monit/issues/5) +- Add support for MMonit HTTPs addresses [\#4](https://github.com/voxpupuli/puppet-monit/issues/4) -This release adds support to Debian Stretch and uses PDK 1.3.2. +**Merged pull requests:** -#### Features -- Added support to Debian Stretch +- Amazon fixed the wrong versioning for Amazon linux 2 [\#8](https://github.com/voxpupuli/puppet-monit/pull/8) ([erik-frontify](https://github.com/erik-frontify)) -## 2018-01-26 - Release 1.1.3 -### Summary +## [v2.0.0](https://github.com/voxpupuli/puppet-monit/tree/v2.0.0) (2018-10-08) -This release benefited from the changes introduced by PDK 1.3 (`pdk convert`) +[Full Changelog](https://github.com/voxpupuli/puppet-monit/compare/v1.4.0...v2.0.0) -## 2016-11-07 - Release 1.1.2 -### Summary -This release adds support to Ubuntu Xenial and improves compatibility with Puppet Server. +**Implemented enhancements:** -#### Features -- Added support to Ubuntu 16.04. +- Add httpd\_allow configuration [\#5](https://github.com/voxpupuli/puppet-monit/issues/5) +- Add support for MMonit HTTPs addresses [\#4](https://github.com/voxpupuli/puppet-monit/issues/4) +- Add httpd\_allow configuration [\#7](https://github.com/voxpupuli/puppet-monit/pull/7) ([FlorentPoinsaut](https://github.com/FlorentPoinsaut)) +- Add support for MMonit HTTPs addresses [\#6](https://github.com/voxpupuli/puppet-monit/pull/6) ([FlorentPoinsaut](https://github.com/FlorentPoinsaut)) -### Bugfixes -- Fixed condition that fails with `strict_variables` enabled on the Puppet Server side. +## [v1.4.0](https://github.com/voxpupuli/puppet-monit/tree/v1.4.0) (2018-08-03) -## 2016-08-30 - Release 1.1.1 -### Summary -This release fixes typo and a bad URL. It is published with [Geppeto](https://puppetlabs.github.io/geppetto/). +[Full Changelog](https://github.com/voxpupuli/puppet-monit/compare/v1.3.0...v1.4.0) -## 2016-08-05 - Release 1.1.0 -### Summary -This release adds support to Debian jessie, OracleLinux and Scientific OSes, as well as a `config_dir_purge` parameter and a lot of great test improvements. +**Merged pull requests:** -#### Features -- Added support to Debian jessie. -- Added support to OracleLinux and Scientific. -- Added `monit_version` fact. -- Added `config_dir_purge` parameter to `monit` class and to the template of configuration file. +- Add amazon linux2 support [\#3](https://github.com/voxpupuli/puppet-monit/pull/3) ([erik-frontify](https://github.com/erik-frontify)) -#### Bugfixes -- Fixed bad dependencies (puppetlabs/stdlib >= 4.6.0 + add puppetlabs/firewall) +## [v1.3.0](https://github.com/voxpupuli/puppet-monit/tree/v1.3.0) (2018-05-05) -#### Tests -- Amazing enhancement of code coverage (special thanks to [Phil Friderici](https://github.com/Phil-Friderici) and [Garrett Honeycutt](https://github.com/ghoneycutt)) -- Puppet v3 (optionally with future parser) and v4 with Ruby versions 1.8.7 (Puppet v3 only), 1.9.3, 2.0.0 and 2.1.0. -- Improvment of style and additional community style checks +[Full Changelog](https://github.com/voxpupuli/puppet-monit/compare/v1.2.0...v1.3.0) -## 2015-08-06 - Release 1.0.0 -### Summary -This release updates metadata to support new version of RedHat family OSes, as well as new features and test improvements. +**Merged pull requests:** -#### Features -- Added support to RedHat family OSes version 7. -- Added configuration option to set an M/Monit report server in Monit configuration file. -- Added support for start delay parameter. -- Made HTTPd authentication by user and password optional. +- Support bionic [\#1](https://github.com/voxpupuli/puppet-monit/pull/1) ([elmobp](https://github.com/elmobp)) -#### Tests -- Added future parser in Travis matrix. -- Added acceptance tests. +## [v1.2.0](https://github.com/voxpupuli/puppet-monit/tree/v1.2.0) (2018-01-26) -##2015-06-06 - Release 0.5.0 -###Summary -This release adds `mail-format` and `alert` parameters to the monit configuration file. +[Full Changelog](https://github.com/voxpupuli/puppet-monit/compare/v1.1.3...v1.2.0) -####Features -- Add `mailformat` parameter to `monit` class and to the template of configuration file. -- Add `alert_emails` parameter to `monit` class and to the template of configuration file. +## [v1.1.3](https://github.com/voxpupuli/puppet-monit/tree/v1.1.3) (2018-01-26) -####Bugfixes -- `ìdfile` parameter does not exist for Monit 4 +[Full Changelog](https://github.com/voxpupuli/puppet-monit/compare/v1.1.2...v1.1.3) -##2015-04-02 - Release 0.4.0 -###Summary -This release adds `logile` and `mailserver` parameters to the monit configuration file. +## [v1.1.2](https://github.com/voxpupuli/puppet-monit/tree/v1.1.2) (2016-11-07) -####Features -- Add `logfile` parameter to `monit` class and to the template of configuration file. -- Add `mailserver` parameter to `monit` class and to the template of configuration file. +[Full Changelog](https://github.com/voxpupuli/puppet-monit/compare/v1.1.1...v1.1.2) -####Bugfixes -- Bad variable use for configuration directory in `monit::check` +## [v1.1.1](https://github.com/voxpupuli/puppet-monit/tree/v1.1.1) (2016-08-30) -##2015-04-01 - Release 0.3.0 -###Summary +[Full Changelog](https://github.com/voxpupuli/puppet-monit/compare/v1.1.0...v1.1.1) -This release adds support for RedHat family OSes. +## [v1.1.0](https://github.com/voxpupuli/puppet-monit/tree/v1.1.0) (2016-08-05) -##2015-02-22 - Release 0.2.0 -###Summary +[Full Changelog](https://github.com/voxpupuli/puppet-monit/compare/v1.0.0...v1.1.0) -This release adds `content` parameter to `monit::check`. +## [v1.0.0](https://github.com/voxpupuli/puppet-monit/tree/v1.0.0) (2015-08-06) -##2015-02-09 - Release 0.1.4 -###Summary +[Full Changelog](https://github.com/voxpupuli/puppet-monit/compare/v0.5.0...v1.0.0) -This release improves the compliance with Debian Squeeze and Ubuntu Lucid. +## [v0.5.0](https://github.com/voxpupuli/puppet-monit/tree/v0.5.0) (2015-06-06) -##2014-12-22 - Release 0.1.3 -###Summary +[Full Changelog](https://github.com/voxpupuli/puppet-monit/compare/v0.4.0...v0.5.0) -This release adds tests and improves the compliance with Puppet Guidelines. +## [v0.4.0](https://github.com/voxpupuli/puppet-monit/tree/v0.4.0) (2015-04-02) -##0.1.2 +[Full Changelog](https://github.com/voxpupuli/puppet-monit/compare/v0.3.0...v0.4.0) -2014-09-18 +## [v0.3.0](https://github.com/voxpupuli/puppet-monit/tree/v0.3.0) (2015-04-01) -* Add parameter `ensure` for `monit::check` - wild -* Fix bad validation for package_name for `monit::check` - Florent Poinsaut +[Full Changelog](https://github.com/voxpupuli/puppet-monit/compare/v0.2.0...v0.3.0) -##0.1.1 -2014-09-15 Florent Poinsaut -* Typo +## [v0.2.0](https://github.com/voxpupuli/puppet-monit/tree/v0.2.0) (2015-02-22) -2014-09-03 https://github.com/wild-r -* Disable validate_absolute_path on check.pp to allow link like 'puppet://...' +[Full Changelog](https://github.com/voxpupuli/puppet-monit/compare/v0.1.4...v0.2.0) -##0.1.0 -2014-08-29 Florent Poinsaut -* Initial release +## [v0.1.4](https://github.com/voxpupuli/puppet-monit/tree/v0.1.4) (2015-02-09) + +[Full Changelog](https://github.com/voxpupuli/puppet-monit/compare/v0.1.3...v0.1.4) + +## [v0.1.3](https://github.com/voxpupuli/puppet-monit/tree/v0.1.3) (2014-12-22) + +[Full Changelog](https://github.com/voxpupuli/puppet-monit/compare/v0.1.2...v0.1.3) + +## [v0.1.2](https://github.com/voxpupuli/puppet-monit/tree/v0.1.2) (2014-09-18) + +[Full Changelog](https://github.com/voxpupuli/puppet-monit/compare/v0.1.1...v0.1.2) + +## [v0.1.1](https://github.com/voxpupuli/puppet-monit/tree/v0.1.1) (2014-09-15) + +[Full Changelog](https://github.com/voxpupuli/puppet-monit/compare/v0.1.0...v0.1.1) + +## [v0.1.0](https://github.com/voxpupuli/puppet-monit/tree/v0.1.0) (2014-08-29) + +[Full Changelog](https://github.com/voxpupuli/puppet-monit/compare/5c2a9c8ed93ee8ff0f6d305042ae8f1e808b6f92...v0.1.0) + + + +\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)* diff --git a/REFERENCE.md b/REFERENCE.md index 0c1b25a..e5168cc 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -66,6 +66,7 @@ The following parameters are available in the `monit` class: * [`service_ensure`](#-monit--service_ensure) * [`service_manage`](#-monit--service_manage) * [`service_name`](#-monit--service_name) +* [`state_dir`](#-monit--state_dir) * [`start_delay`](#-monit--start_delay) * [`service_enable`](#-monit--service_enable) @@ -294,6 +295,14 @@ Tells Puppet what Monit service to manage. Default value: 'monit' Default value: `$monit::params::service_name` +##### `state_dir` + +Data type: `Stdlib::Absolutepath` + +Tells Puppet where Monit should place state files. Default value: varies with operating system + +Default value: `$monit::params::state_dir` + ##### `start_delay` Data type: `Optional[Integer[1]]` diff --git a/manifests/check.pp b/manifests/check.pp index b416ac9..b443a91 100644 --- a/manifests/check.pp +++ b/manifests/check.pp @@ -29,7 +29,7 @@ file { "${monit::config_dir}/${name}": ensure => $ensure, owner => 'root', - group => 'root', + group => $monit::root_group, mode => '0644', source => $source, content => $content, diff --git a/manifests/config.pp b/manifests/config.pp index adb5302..02d2250 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -8,10 +8,11 @@ fail("Use of private class ${name} by ${caller_module_name}") } - file { '/var/lib/monit': + file { 'monit_state_dir': ensure => directory, + path => $monit::state_dir, owner => 'root', - group => 'root', + group => $monit::root_group, mode => '0755', } @@ -19,7 +20,7 @@ ensure => directory, path => $monit::config_dir, owner => 'root', - group => 'root', + group => $monit::root_group, mode => '0755', purge => $monit::config_dir_purge, recurse => $monit::config_dir_purge, @@ -30,7 +31,7 @@ ensure => file, path => $monit::config_file, owner => 'root', - group => 'root', + group => $monit::root_group, mode => '0600', content => template('monit/monitrc.erb'), require => Package['monit'], diff --git a/manifests/init.pp b/manifests/init.pp index aa8ec20..fa24f58 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -99,6 +99,9 @@ # @param service_name # Tells Puppet what Monit service to manage. Default value: 'monit' # +# @param state_dir +# Tells Puppet where Monit should place state files. Default value: varies with operating system +# # @param start_delay *Requires at least Monit 5.0* # If set, Monit will wait the specified time in seconds before it starts checking services. Default value: undef # @@ -131,6 +134,8 @@ Boolean $service_manage = $monit::params::service_manage, String $service_name = $monit::params::service_name, Optional[Integer[1]] $start_delay = $monit::params::start_delay, + Stdlib::Absolutepath $state_dir = $monit::params::state_dir + ) inherits monit::params { if $logfile and !($logfile =~ /^syslog(\s+facility\s+log_(local[0-7]|daemon))?/) { assert_type(Stdlib::Absolutepath, $logfile) diff --git a/manifests/params.pp b/manifests/params.pp index d0e0199..ac84230 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -37,12 +37,24 @@ $monit_version = '5' $default_file_content = 'START=yes' $service_hasstatus = true + $state_dir = '/var/lib/monit' + $root_group = 'root' } 'RedHat': { $config_dir = '/etc/monit.d' $service_hasstatus = true $monit_version = '5' $config_file = '/etc/monitrc' + $state_dir = '/var/lib/monit' + $root_group = 'root' + } + 'FreeBSD':{ + $config_dir = '/usr/local/etc/monit.d' + $service_hasstatus = true + $monit_version = '5' + $config_file = '/usr/local/etc/monitrc' + $state_dir = '/var/tmp/monit' + $root_group = 'wheel' } default: { fail("monit supports osfamilies Debian and RedHat. Detected osfamily is <${facts['os']['family']}>.") diff --git a/manifests/service.pp b/manifests/service.pp index c76250a..4446d46 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -23,7 +23,7 @@ hasrestart => true, hasstatus => $monit::service_hasstatus, subscribe => [ - File['/var/lib/monit'], + File['monit_state_dir'], File['monit_config_dir'], File['monit_config'], ], diff --git a/metadata.json b/metadata.json index 4f172fc..3ee9626 100644 --- a/metadata.json +++ b/metadata.json @@ -80,6 +80,13 @@ "operatingsystemrelease": [ "7" ] + }, + { + "operatingsystem": "FreeBSD", + "operatingsystemrelease": [ + "13", + "14" + ] } ], "requirements": [ diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index e6b15f8..5ec6b5f 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -12,17 +12,28 @@ config_dir = '/etc/monit/conf.d' monit_version = '5' default_file_content = 'START=yes' + state_dir = '/var/lib/monit' service_hasstatus = true + root_group = 'root' when 'RedHat' config_dir = '/etc/monit.d' service_hasstatus = true monit_version = '5' + state_dir = '/var/lib/monit' + root_group = 'root' config_file = case facts[:os]['name'] when 'Amazon' '/etc/monit.conf' else '/etc/monitrc' end + when 'FreeBSD' + config_dir = '/usr/local/etc/monit.d' + service_hasstatus = true + monit_version = '5' + config_file = '/usr/local/etc/monitrc' + state_dir = '/var/tmp/monit' + root_group = 'wheel' else raise 'unsupported osfamily detected' end @@ -37,17 +48,18 @@ end it do - is_expected.to contain_file('/var/lib/monit').with('ensure' => 'directory', - 'owner' => 'root', - 'group' => 'root', - 'mode' => '0755') + is_expected.to contain_file('monit_state_dir').with('ensure' => 'directory', + 'path' => state_dir, + 'owner' => 'root', + 'group' => root_group, + 'mode' => '0755') end it do is_expected.to contain_file('monit_config_dir').with('ensure' => 'directory', 'path' => config_dir, 'owner' => 'root', - 'group' => 'root', + 'group' => root_group, 'mode' => '0755', 'purge' => false, 'recurse' => false, @@ -58,7 +70,7 @@ is_expected.to contain_file('monit_config').with('ensure' => 'file', 'path' => config_file, 'owner' => 'root', - 'group' => 'root', + 'group' => root_group, 'mode' => '0600', 'require' => 'Package[monit]') end @@ -87,7 +99,7 @@ 'hasrestart' => true, 'hasstatus' => service_hasstatus, 'subscribe' => [ - 'File[/var/lib/monit]', + 'File[monit_state_dir]', 'File[monit_config_dir]', 'File[monit_config]', ]) diff --git a/spec/defines/check_spec.rb b/spec/defines/check_spec.rb index 834fd28..d82ddbc 100644 --- a/spec/defines/check_spec.rb +++ b/spec/defines/check_spec.rb @@ -12,25 +12,33 @@ facts end - confdir = if facts[:os]['family'] == 'RedHat' - '/etc/monit.d' - else - '/etc/monit/conf.d' - end + case facts[:os]['family'] + when 'Debian' + config_dir = '/etc/monit/conf.d' + root_group = 'root' + when 'RedHat' + config_dir = '/etc/monit.d' + root_group = 'root' + when 'FreeBSD' + config_dir = '/usr/local/etc/monit.d' + root_group = 'wheel' + else + raise 'unsupported osfamily detected' + end context 'with default values for parameters' do it { is_expected.to compile.with_all_deps } it { is_expected.to contain_class('monit') } it do - is_expected.to contain_file("#{confdir}/test").with('ensure' => 'present', - 'owner' => 'root', - 'group' => 'root', - 'mode' => '0644', - 'source' => nil, - 'content' => nil, - 'notify' => 'Service[monit]', - 'require' => 'Package[monit]') + is_expected.to contain_file("#{config_dir}/test").with('ensure' => 'present', + 'owner' => 'root', + 'group' => root_group, + 'mode' => '0644', + 'source' => nil, + 'content' => nil, + 'notify' => 'Service[monit]', + 'require' => 'Package[monit]') end end @@ -43,14 +51,14 @@ end it do - is_expected.to contain_file("#{confdir}/test").with('ensure' => value, - 'owner' => 'root', - 'group' => 'root', - 'mode' => '0644', - 'source' => nil, - 'content' => nil, - 'notify' => 'Service[monit]', - 'require' => 'Package[monit]') + is_expected.to contain_file("#{config_dir}/test").with('ensure' => value, + 'owner' => 'root', + 'group' => root_group, + 'mode' => '0644', + 'source' => nil, + 'content' => nil, + 'notify' => 'Service[monit]', + 'require' => 'Package[monit]') end end end @@ -70,14 +78,14 @@ end it do - is_expected.to contain_file("#{confdir}/test").with('ensure' => 'present', - 'owner' => 'root', - 'group' => 'root', - 'mode' => '0644', - 'source' => nil, - 'content' => content, - 'notify' => 'Service[monit]', - 'require' => 'Package[monit]') + is_expected.to contain_file("#{config_dir}/test").with('ensure' => 'present', + 'owner' => 'root', + 'group' => root_group, + 'mode' => '0644', + 'source' => nil, + 'content' => content, + 'notify' => 'Service[monit]', + 'require' => 'Package[monit]') end end @@ -89,14 +97,14 @@ end it do - is_expected.to contain_file("#{confdir}/test").with('ensure' => 'present', - 'owner' => 'root', - 'group' => 'root', - 'mode' => '0644', - 'source' => 'puppet:///modules/monit/ntp', - 'content' => nil, - 'notify' => 'Service[monit]', - 'require' => 'Package[monit]') + is_expected.to contain_file("#{config_dir}/test").with('ensure' => 'present', + 'owner' => 'root', + 'group' => root_group, + 'mode' => '0644', + 'source' => 'puppet:///modules/monit/ntp', + 'content' => nil, + 'notify' => 'Service[monit]', + 'require' => 'Package[monit]') end end diff --git a/spec/fixtures/monitrc.FreeBSD b/spec/fixtures/monitrc.FreeBSD new file mode 100644 index 0000000..18b25ac --- /dev/null +++ b/spec/fixtures/monitrc.FreeBSD @@ -0,0 +1,11 @@ +# monitrc: Managed by puppet. +# +set daemon 120 +set logfile /var/log/monit.log +set idfile /var/tmp/monit/id +set statefile /var/tmp/monit/state +set eventqueue + basedir /var/tmp/monit/events + slots 100 + +include /usr/local/etc/monit.d/* diff --git a/templates/monitrc.erb b/templates/monitrc.erb index 6b8a8d6..6ef01c6 100644 --- a/templates/monitrc.erb +++ b/templates/monitrc.erb @@ -8,9 +8,9 @@ with start delay <%= @start_delay %> set logfile <%= @logfile %> <%- end -%> <%- if scope.function_versioncmp([@monit_version_real, '5']) >= 0 -%> -set idfile /var/lib/monit/id +set idfile <%= @state_dir %>/id <%- end -%> -set statefile /var/lib/monit/state +set statefile <%= @state_dir %>/state <%- if @mailserver -%> set mailserver <%= @mailserver %> <%- end -%> @@ -25,7 +25,7 @@ set mail-format { set alert <%= email %> <%- end -%> set eventqueue - basedir /var/lib/monit/events + basedir <%= @state_dir %>/events slots 100 <%- if @httpd == true -%> set httpd port <%= @httpd_port %> and