From ecb46bdb164f6bf161d645bc4a16304aa4fa57c5 Mon Sep 17 00:00:00 2001 From: markuszilch Date: Tue, 13 Feb 2024 15:14:42 +0100 Subject: [PATCH 01/22] remove pins from fixtures and delete symlink --- .fixtures.yml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/.fixtures.yml b/.fixtures.yml index 998bf07..7cae334 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -1,10 +1,4 @@ fixtures: repositories: - 'stdlib': - repo: 'https://github.com/puppetlabs/puppetlabs-stdlib.git' - ref: '4.6.0' - 'firewall': - repo: 'https://github.com/puppetlabs/puppetlabs-firewall.git' - ref: '1.7.1' - symlinks: - 'monit': "#{source_dir}" + 'stdlib': 'https://github.com/puppetlabs/puppetlabs-stdlib.git' + 'firewall': 'https://github.com/puppetlabs/puppetlabs-firewall.git' From 989d75432d6facdf0f5982a4774d99d452688b52 Mon Sep 17 00:00:00 2001 From: markuszilch Date: Tue, 13 Feb 2024 17:09:46 +0100 Subject: [PATCH 02/22] replace legacy is_string function with datatype check --- manifests/init.pp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index c1dc47b..0e9f4c8 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -133,43 +133,43 @@ Optional[Integer[1]] $start_delay = $monit::params::start_delay, ) inherits monit::params { # - if is_string($httpd) == true { + if $httpd =~ String { $httpd_bool = str2bool($httpd) } else { $httpd_bool = $httpd } - if is_string($manage_firewall) == true { + if $manage_firewall =~ String { $manage_firewall_bool = str2bool($manage_firewall) } else { $manage_firewall_bool = $manage_firewall } - if is_string($service_enable) == true { + if $service_enable =~ String { $service_enable_bool = str2bool($service_enable) } else { $service_enable_bool = $service_enable } - if is_string($service_manage) == true { + if $service_manage =~ String { $service_manage_bool = str2bool($service_manage) } else { $service_manage_bool = $service_manage } - if is_string($mmonit_https) == true { + if $mmonit_https =~ String { $mmonit_https_bool = str2bool($mmonit_https) } else { $mmonit_https_bool = $mmonit_https } - if is_string($mmonit_without_credential) == true { + if $mmonit_without_credential =~ String { $mmonit_without_credential_bool = str2bool($mmonit_without_credential) } else { $mmonit_without_credential_bool = $mmonit_without_credential } - if is_string($config_dir_purge) == true { + if $config_dir_purge =~ String { $config_dir_purge_bool = str2bool($config_dir_purge) } else { $config_dir_purge_bool = $config_dir_purge From 30849e24b1cbc684a649eb6bf17350d09b83148f Mon Sep 17 00:00:00 2001 From: markuszilch Date: Tue, 13 Feb 2024 17:17:05 +0100 Subject: [PATCH 03/22] use absolutepath type instead of validate function --- REFERENCE.md | 4 ++-- manifests/init.pp | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/REFERENCE.md b/REFERENCE.md index 757e6d3..1979508 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -87,7 +87,7 @@ Default value: `$monit::params::check_interval` ##### `config_file` -Data type: `String` +Data type: `Stdlib::Absolutepath` Specifies a path to the main config file. Default value: varies with operating system @@ -95,7 +95,7 @@ Default value: `$monit::params::config_file` ##### `config_dir` -Data type: `String` +Data type: `Stdlib::Absolutepath` Specifies a path to the config directory. Default value: varies with operating system diff --git a/manifests/init.pp b/manifests/init.pp index 0e9f4c8..a85140f 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -105,8 +105,8 @@ class monit ( Array[String] $alert_emails = $monit::params::alert_emails, Integer[1] $check_interval = $monit::params::check_interval, - String $config_file = $monit::params::config_file, - String $config_dir = $monit::params::config_dir, + Stdlib::Absolutepath $config_file = $monit::params::config_file, + Stdlib::Absolutepath $config_dir = $monit::params::config_dir, Variant[Boolean, Enum['true', 'false']] $config_dir_purge = $monit::params::config_dir_purge, Variant[Boolean, Enum['true', 'false']] $httpd = $monit::params::httpd, Integer[1, 65535] $httpd_port = $monit::params::httpd_port, @@ -177,8 +177,8 @@ # # - validate_absolute_path($config_file) - validate_absolute_path($config_dir) + $config_file + $config_dir if $logfile and !($logfile =~ /^syslog(\s+facility\s+log_(local[0-7]|daemon))?/) { validate_absolute_path($logfile) From 264cff18a632130afae7469ff04c5c03485a33cc Mon Sep 17 00:00:00 2001 From: markuszilch Date: Tue, 13 Feb 2024 17:18:48 +0100 Subject: [PATCH 04/22] really remove validation --- manifests/init.pp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index a85140f..698c0d0 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -176,10 +176,6 @@ } # - # - $config_file - $config_dir - if $logfile and !($logfile =~ /^syslog(\s+facility\s+log_(local[0-7]|daemon))?/) { validate_absolute_path($logfile) } From 51a666362db6b54dc4cb4a817fdae679f3c62d8a Mon Sep 17 00:00:00 2001 From: markuszilch Date: Tue, 13 Feb 2024 17:25:04 +0100 Subject: [PATCH 05/22] fix another path with assert_type --- manifests/init.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index 698c0d0..26fd7db 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -177,7 +177,7 @@ # if $logfile and !($logfile =~ /^syslog(\s+facility\s+log_(local[0-7]|daemon))?/) { - validate_absolute_path($logfile) + assert_type(Stdlib::Absolutepath, $logfile) } # From cc2f29375da7212e439df8fb2d209e43e89364c5 Mon Sep 17 00:00:00 2001 From: markuszilch Date: Tue, 13 Feb 2024 17:30:07 +0100 Subject: [PATCH 06/22] remove unnecessary commments --- manifests/init.pp | 3 --- 1 file changed, 3 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 26fd7db..15c7a72 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -132,7 +132,6 @@ String $service_name = $monit::params::service_name, Optional[Integer[1]] $start_delay = $monit::params::start_delay, ) inherits monit::params { - # if $httpd =~ String { $httpd_bool = str2bool($httpd) } else { @@ -174,12 +173,10 @@ } else { $config_dir_purge_bool = $config_dir_purge } - # if $logfile and !($logfile =~ /^syslog(\s+facility\s+log_(local[0-7]|daemon))?/) { assert_type(Stdlib::Absolutepath, $logfile) } - # # Use the monit_version fact if available, else use the default for the # platform. From 5399add5225be9ced4aace9a76a914040673b62f Mon Sep 17 00:00:00 2001 From: markuszilch Date: Tue, 13 Feb 2024 21:39:34 +0100 Subject: [PATCH 07/22] replace legacy firewall parameter action with jump --- manifests/firewall.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/firewall.pp b/manifests/firewall.pp index 37a9d2e..cf10f1c 100644 --- a/manifests/firewall.pp +++ b/manifests/firewall.pp @@ -11,7 +11,7 @@ if $monit::httpd_bool and $monit::manage_firewall_bool { if defined('::firewall') { firewall { "${monit::httpd_port} allow Monit inbound traffic": - action => 'accept', + jump => 'accept', dport => $monit::httpd_port, proto => 'tcp', } From 3714d6dec30d904a40dc823220e99e0278852cfe Mon Sep 17 00:00:00 2001 From: markuszilch Date: Tue, 13 Feb 2024 21:41:06 +0100 Subject: [PATCH 08/22] lint_fix --- manifests/firewall.pp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/manifests/firewall.pp b/manifests/firewall.pp index cf10f1c..0a1ec06 100644 --- a/manifests/firewall.pp +++ b/manifests/firewall.pp @@ -11,9 +11,9 @@ if $monit::httpd_bool and $monit::manage_firewall_bool { if defined('::firewall') { firewall { "${monit::httpd_port} allow Monit inbound traffic": - jump => 'accept', - dport => $monit::httpd_port, - proto => 'tcp', + jump => 'accept', + dport => $monit::httpd_port, + proto => 'tcp', } } } From 86ae20ded695d1ae981b91f685427045475b158c Mon Sep 17 00:00:00 2001 From: markuszilch Date: Tue, 13 Feb 2024 21:43:13 +0100 Subject: [PATCH 09/22] change spec test to reflect jump firewall parameter --- spec/classes/init_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index 6663ebd..9fab2c8 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -159,7 +159,7 @@ end it do - is_expected.to contain_firewall('2812 allow Monit inbound traffic').with('action' => 'accept', + is_expected.to contain_firewall('2812 allow Monit inbound traffic').with('jump' => 'accept', 'dport' => '2812', 'proto' => 'tcp') end From ab162f406e0154c2b58cea85b40d912b08b29632 Mon Sep 17 00:00:00 2001 From: markuszilch Date: Tue, 13 Feb 2024 21:44:56 +0100 Subject: [PATCH 10/22] rubocop autocorrect --- spec/classes/init_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index 9fab2c8..764657a 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -160,8 +160,8 @@ it do is_expected.to contain_firewall('2812 allow Monit inbound traffic').with('jump' => 'accept', - 'dport' => '2812', - 'proto' => 'tcp') + 'dport' => '2812', + 'proto' => 'tcp') end end From 234f496fd5906edc3996e5c1b95b1bb59a48d017 Mon Sep 17 00:00:00 2001 From: markuszilch Date: Tue, 13 Feb 2024 22:26:18 +0100 Subject: [PATCH 11/22] remove type tests, we have typing in puppet now --- spec/classes/init_spec.rb | 149 -------------------------------------- 1 file changed, 149 deletions(-) diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index 764657a..adf8dad 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -316,153 +316,4 @@ end end end - - describe 'failures' do - let(:facts) do - { - osfamily: 'Debian', - lsbdistcodename: 'squeeze', - monit_version: '5', - } - end - - [-1, 65_536].each do |value| - context "when httpd_port is set to invalid value <#{value}>" do - let(:params) do - { - httpd: true, - httpd_port: value, - httpd_address: 'otherhost', - httpd_user: 'tester', - httpd_password: 'Passw0rd', - } - end - - it 'fails' do - is_expected.to compile.and_raise_error(%r{expects an Integer\[1, 65535\] value}) - end - end - end - - context 'when check_interval is set to invalid value <0>' do - let(:params) { { check_interval: 0 } } - - it 'fails' do - is_expected.to compile.and_raise_error(%r{expects an Integer\[1}) - end - end - - context 'when start_delay is set to invalid value <0>' do - let(:params) { { start_delay: 0 } } - - it 'fails' do - is_expected.to compile.and_raise_error(%r{expects a value of type Undef or Integer\[1}) - end - end - end - - describe 'variable type and content validations' do - # set needed custom facts and variables - let(:facts) do - { - osfamily: 'Debian', - operatingsystemrelease: '6.0', - operatingsystemmajrelease: '6', - lsbdistcodename: 'squeeze', - monit_version: '5', - } - end - let(:validation_params) do - { - # :param => 'value', - } - end - - validations = { - 'absolute_path' => { - name: %w[config_file config_dir], - valid: ['/absolute/filepath', '/absolute/directory/'], - invalid: ['invalid', 3, 2.42, ['array'], { 'ha' => 'sh' }], - message: '(expects a String value|is not an absolute path)', - }, - 'array' => { - name: ['alert_emails'], - valid: [%w[valid array]], - invalid: ['string', { 'ha' => 'sh' }, 3, 2.42, true], - message: 'expects an Array value', - }, - 'bool_stringified' => { - name: %w[httpd manage_firewall service_enable service_manage mmonit_https mmonit_without_credential config_dir_purge], - valid: [true, 'true', false, 'false'], - invalid: ['invalid', 3, 2.42, ['array'], { 'ha' => 'sh' }, nil], - message: 'expects a value of type Boolean or Enum', - }, - 'integer' => { - name: %w[check_interval httpd_port mmonit_port], - valid: [242], - invalid: [2.42, 'invalid', ['array'], { 'ha' => 'sh ' }, true, false, nil], - message: 'expects an Integer', - }, - 'optional_integer' => { - name: ['start_delay'], - valid: [242], - invalid: [2.42, 'invalid', ['array'], { 'ha' => 'sh ' }, true, false, nil], - message: 'expects a value of type Undef or Integer', - }, - 'optional_logfile' => { - name: ['logfile'], - valid: ['/absolute/filepath', '/absolute/directory/', 'syslog', 'syslog facility log_local0'], - invalid: ['invalid', 3, 2.42, ['array'], { 'ha' => 'sh' }], - message: '(expects a value of type Undef or String|is not an absolute path)', - }, - 'optional_hash' => { - name: ['mailformat'], - valid: [{ 'ha' => 'sh' }], - invalid: ['string', 3, 2.42, ['array'], true, false, nil], - message: 'expects a value of type Undef or Hash', - }, - 'optional_string' => { - name: %w[mailserver mmonit_address], - valid: ['present'], - invalid: [['array'], { 'ha' => 'sh' }], - message: 'expects a value of type Undef or String', - }, - 'string' => { - name: %w[httpd_address httpd_allow httpd_user httpd_password - package_ensure package_name service_name mmonit_user - mmonit_password], - valid: ['present'], - invalid: [['array'], { 'ha' => 'sh' }], - message: 'expects a String value', - }, - 'service_ensure_string' => { - name: ['service_ensure'], - valid: ['running'], - invalid: [['array'], { 'ha' => 'sh' }], - message: 'expects a match for Enum\[\'running\', \'stopped\'\]', - }, - } - - validations.sort.each do |type, var| - var[:name].each do |var_name| - var[:valid].each do |valid| - context "with #{var_name} (#{type}) set to valid #{valid} (as #{valid.class})" do - let(:params) { validation_params.merge("#{var_name}": valid) } - - it { is_expected.to compile } - end - end - - var[:invalid].each do |invalid| - context "with #{var_name} (#{type}) set to invalid #{invalid} (as #{invalid.class})" do - let(:params) { validation_params.merge("#{var_name}": invalid) } - - it 'fails' do - is_expected.to compile.and_raise_error(%r{#{var[:message]}}) - end - end - end - end # var[:name].each - end # validations.sort.each - end # describe 'variable type and content validations' end From 887024dfbb77f66a0b783e99e48a964baf3a442c Mon Sep 17 00:00:00 2001 From: markuszilch Date: Thu, 15 Feb 2024 09:58:12 +0100 Subject: [PATCH 12/22] set httpd to strictly be boolean --- manifests/init.pp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 15c7a72..1f5aa80 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -108,7 +108,7 @@ Stdlib::Absolutepath $config_file = $monit::params::config_file, Stdlib::Absolutepath $config_dir = $monit::params::config_dir, Variant[Boolean, Enum['true', 'false']] $config_dir_purge = $monit::params::config_dir_purge, - Variant[Boolean, Enum['true', 'false']] $httpd = $monit::params::httpd, + Boolean $httpd = $monit::params::httpd, Integer[1, 65535] $httpd_port = $monit::params::httpd_port, String $httpd_address = $monit::params::httpd_address, String $httpd_allow = $monit::params::httpd_allow, @@ -132,11 +132,6 @@ String $service_name = $monit::params::service_name, Optional[Integer[1]] $start_delay = $monit::params::start_delay, ) inherits monit::params { - if $httpd =~ String { - $httpd_bool = str2bool($httpd) - } else { - $httpd_bool = $httpd - } if $manage_firewall =~ String { $manage_firewall_bool = str2bool($manage_firewall) From d9d8159059b4113fde0b50af29bf9e015a5fcfd5 Mon Sep 17 00:00:00 2001 From: markuszilch Date: Thu, 15 Feb 2024 09:59:14 +0100 Subject: [PATCH 13/22] set manage_firewall to strictly be boolean --- manifests/init.pp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 1f5aa80..e75e9e1 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -117,7 +117,7 @@ Optional[String] $logfile = $monit::params::logfile, Optional[String] $mailserver = $monit::params::mailserver, Optional[Hash] $mailformat = $monit::params::mailformat, - Variant[Boolean, Enum['true', 'false']] $manage_firewall = $monit::params::manage_firewall, + Boolean $manage_firewall = $monit::params::manage_firewall, Optional[String] $mmonit_address = $monit::params::mmonit_address, Variant[Boolean, Enum['true', 'false']] $mmonit_https = $monit::params::mmonit_https, Integer[1, 65535] $mmonit_port = $monit::params::mmonit_port, @@ -133,12 +133,6 @@ Optional[Integer[1]] $start_delay = $monit::params::start_delay, ) inherits monit::params { - if $manage_firewall =~ String { - $manage_firewall_bool = str2bool($manage_firewall) - } else { - $manage_firewall_bool = $manage_firewall - } - if $service_enable =~ String { $service_enable_bool = str2bool($service_enable) } else { From e70025dc3c59eca0d95e875d32d43b8e6ff51cb7 Mon Sep 17 00:00:00 2001 From: markuszilch Date: Thu, 15 Feb 2024 10:00:42 +0100 Subject: [PATCH 14/22] set service_enable to strictly be boolean --- manifests/init.pp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index e75e9e1..f89502b 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -126,19 +126,13 @@ Variant[Boolean, Enum['true', 'false']] $mmonit_without_credential = $monit::params::mmonit_without_credential, String $package_ensure = $monit::params::package_ensure, String $package_name = $monit::params::package_name, - Variant[Boolean, Enum['true', 'false']] $service_enable = $monit::params::service_enable, + Boolean $service_enable = $monit::params::service_enable, Enum['running', 'stopped'] $service_ensure = $monit::params::service_ensure, Variant[Boolean, Enum['true', 'false']] $service_manage = $monit::params::service_manage, String $service_name = $monit::params::service_name, Optional[Integer[1]] $start_delay = $monit::params::start_delay, ) inherits monit::params { - if $service_enable =~ String { - $service_enable_bool = str2bool($service_enable) - } else { - $service_enable_bool = $service_enable - } - if $service_manage =~ String { $service_manage_bool = str2bool($service_manage) } else { From e468e53fbc4575861a017e3e8c0102a04a98ea93 Mon Sep 17 00:00:00 2001 From: markuszilch Date: Thu, 15 Feb 2024 10:01:25 +0100 Subject: [PATCH 15/22] set service_manage to strictly be boolean --- manifests/init.pp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index f89502b..c49df8d 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -128,17 +128,11 @@ String $package_name = $monit::params::package_name, Boolean $service_enable = $monit::params::service_enable, Enum['running', 'stopped'] $service_ensure = $monit::params::service_ensure, - Variant[Boolean, Enum['true', 'false']] $service_manage = $monit::params::service_manage, + Boolean $service_manage = $monit::params::service_manage, String $service_name = $monit::params::service_name, Optional[Integer[1]] $start_delay = $monit::params::start_delay, ) inherits monit::params { - if $service_manage =~ String { - $service_manage_bool = str2bool($service_manage) - } else { - $service_manage_bool = $service_manage - } - if $mmonit_https =~ String { $mmonit_https_bool = str2bool($mmonit_https) } else { From 899daad7b896feefe50aa9826102a1b62b33aea8 Mon Sep 17 00:00:00 2001 From: markuszilch Date: Thu, 15 Feb 2024 10:03:47 +0100 Subject: [PATCH 16/22] set mmonit_https to strictly be boolean --- manifests/init.pp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index c49df8d..93cb42a 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -119,7 +119,7 @@ Optional[Hash] $mailformat = $monit::params::mailformat, Boolean $manage_firewall = $monit::params::manage_firewall, Optional[String] $mmonit_address = $monit::params::mmonit_address, - Variant[Boolean, Enum['true', 'false']] $mmonit_https = $monit::params::mmonit_https, + Boolean $mmonit_https = $monit::params::mmonit_https, Integer[1, 65535] $mmonit_port = $monit::params::mmonit_port, String $mmonit_user = $monit::params::mmonit_user, String $mmonit_password = $monit::params::mmonit_password, @@ -133,12 +133,6 @@ Optional[Integer[1]] $start_delay = $monit::params::start_delay, ) inherits monit::params { - if $mmonit_https =~ String { - $mmonit_https_bool = str2bool($mmonit_https) - } else { - $mmonit_https_bool = $mmonit_https - } - if $mmonit_without_credential =~ String { $mmonit_without_credential_bool = str2bool($mmonit_without_credential) } else { From a1dce22c87a28ac8565cbc18f81aedc1b539ecef Mon Sep 17 00:00:00 2001 From: markuszilch Date: Thu, 15 Feb 2024 10:04:40 +0100 Subject: [PATCH 17/22] set mmonit_without_credentials to strictly be boolean --- manifests/init.pp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 93cb42a..055b480 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -123,7 +123,7 @@ Integer[1, 65535] $mmonit_port = $monit::params::mmonit_port, String $mmonit_user = $monit::params::mmonit_user, String $mmonit_password = $monit::params::mmonit_password, - Variant[Boolean, Enum['true', 'false']] $mmonit_without_credential = $monit::params::mmonit_without_credential, + Boolean $mmonit_without_credential = $monit::params::mmonit_without_credential, String $package_ensure = $monit::params::package_ensure, String $package_name = $monit::params::package_name, Boolean $service_enable = $monit::params::service_enable, @@ -133,12 +133,6 @@ Optional[Integer[1]] $start_delay = $monit::params::start_delay, ) inherits monit::params { - if $mmonit_without_credential =~ String { - $mmonit_without_credential_bool = str2bool($mmonit_without_credential) - } else { - $mmonit_without_credential_bool = $mmonit_without_credential - } - if $config_dir_purge =~ String { $config_dir_purge_bool = str2bool($config_dir_purge) } else { From 543112123c3a97a30cebbb276898d556b511c6a2 Mon Sep 17 00:00:00 2001 From: markuszilch Date: Thu, 15 Feb 2024 10:05:41 +0100 Subject: [PATCH 18/22] set config_dir_purge to strictly be boolean --- manifests/init.pp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 055b480..89cd75b 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -107,7 +107,7 @@ Integer[1] $check_interval = $monit::params::check_interval, Stdlib::Absolutepath $config_file = $monit::params::config_file, Stdlib::Absolutepath $config_dir = $monit::params::config_dir, - Variant[Boolean, Enum['true', 'false']] $config_dir_purge = $monit::params::config_dir_purge, + Boolean $config_dir_purge = $monit::params::config_dir_purge, Boolean $httpd = $monit::params::httpd, Integer[1, 65535] $httpd_port = $monit::params::httpd_port, String $httpd_address = $monit::params::httpd_address, @@ -133,12 +133,6 @@ Optional[Integer[1]] $start_delay = $monit::params::start_delay, ) inherits monit::params { - if $config_dir_purge =~ String { - $config_dir_purge_bool = str2bool($config_dir_purge) - } else { - $config_dir_purge_bool = $config_dir_purge - } - if $logfile and !($logfile =~ /^syslog(\s+facility\s+log_(local[0-7]|daemon))?/) { assert_type(Stdlib::Absolutepath, $logfile) } From 239c7addc591fa632ae120ad6b3677dee86b9dbe Mon Sep 17 00:00:00 2001 From: markuszilch Date: Thu, 15 Feb 2024 10:08:15 +0100 Subject: [PATCH 19/22] regenerate reference --- REFERENCE.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/REFERENCE.md b/REFERENCE.md index 1979508..0c1b25a 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -103,7 +103,7 @@ Default value: `$monit::params::config_dir` ##### `config_dir_purge` -Data type: `Variant[Boolean, Enum['true', 'false']]` +Data type: `Boolean` Specifies if unmanaged files in the config directory should be purged. Default value: 'false' @@ -111,7 +111,7 @@ Default value: `$monit::params::config_dir_purge` ##### `httpd` -Data type: `Variant[Boolean, Enum['true', 'false']]` +Data type: `Boolean` Specifies whether to enable the Monit Dashboard. Default value: 'false' @@ -186,7 +186,7 @@ Default value: `$monit::params::mailformat` ##### `manage_firewall` -Data type: `Variant[Boolean, Enum['true', 'false']]` +Data type: `Boolean` If true and if puppetlabs-firewall module is present, Puppet manages firewall to allow HTTP access for Monit Dashboard. Default value: 'false' @@ -205,7 +205,7 @@ Default value: `$monit::params::mmonit_address` ##### `mmonit_https` -Data type: `Variant[Boolean, Enum['true', 'false']]` +Data type: `Boolean` *Requires at least Monit 5.0*
Specifies wheither the protocol of the M/Monit server is HTTPs. Default value: 'true' @@ -243,7 +243,7 @@ Default value: `$monit::params::mmonit_password` ##### `mmonit_without_credential` -Data type: `Variant[Boolean, Enum['true', 'false']]` +Data type: `Boolean` *Requires at least Monit 5.0*
By default Monit registers credentials with M/Monit so M/Monit can smoothly communicate back to Monit and you don't have to register @@ -280,7 +280,7 @@ Default value: `$monit::params::service_ensure` ##### `service_manage` -Data type: `Variant[Boolean, Enum['true', 'false']]` +Data type: `Boolean` Tells Puppet whether to manage the Monit service. Default value: 'true' @@ -305,7 +305,7 @@ Default value: `$monit::params::start_delay` ##### `service_enable` -Data type: `Variant[Boolean, Enum['true', 'false']]` +Data type: `Boolean` From c11940e85666692d8542afe5dc259f8b1821ad64 Mon Sep 17 00:00:00 2001 From: markuszilch Date: Thu, 15 Feb 2024 10:09:51 +0100 Subject: [PATCH 20/22] lint_fix --- manifests/init.pp | 1 - 1 file changed, 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index 89cd75b..aa8ec20 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -132,7 +132,6 @@ String $service_name = $monit::params::service_name, Optional[Integer[1]] $start_delay = $monit::params::start_delay, ) inherits monit::params { - if $logfile and !($logfile =~ /^syslog(\s+facility\s+log_(local[0-7]|daemon))?/) { assert_type(Stdlib::Absolutepath, $logfile) } From 5f53294a5b130ac2a2d13dce552f95b06f4effc2 Mon Sep 17 00:00:00 2001 From: markuszilch Date: Thu, 15 Feb 2024 10:16:44 +0100 Subject: [PATCH 21/22] reference correct variable --- manifests/firewall.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/firewall.pp b/manifests/firewall.pp index 0a1ec06..86abbc4 100644 --- a/manifests/firewall.pp +++ b/manifests/firewall.pp @@ -8,7 +8,7 @@ fail("Use of private class ${name} by ${caller_module_name}") } - if $monit::httpd_bool and $monit::manage_firewall_bool { + if $monit::httpd and $monit::manage_firewall { if defined('::firewall') { firewall { "${monit::httpd_port} allow Monit inbound traffic": jump => 'accept', From d8640dd571931362912670b64c2c201228f319e2 Mon Sep 17 00:00:00 2001 From: markuszilch Date: Thu, 15 Feb 2024 10:22:45 +0100 Subject: [PATCH 22/22] cleanup last _bool variables --- manifests/config.pp | 4 ++-- manifests/service.pp | 2 +- templates/monitrc.erb | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/manifests/config.pp b/manifests/config.pp index b20ba5e..adb5302 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -21,8 +21,8 @@ owner => 'root', group => 'root', mode => '0755', - purge => $monit::config_dir_purge_bool, - recurse => $monit::config_dir_purge_bool, + purge => $monit::config_dir_purge, + recurse => $monit::config_dir_purge, require => Package['monit'], } diff --git a/manifests/service.pp b/manifests/service.pp index fa6979d..4275b88 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -8,7 +8,7 @@ fail("Use of private class ${name} by ${caller_module_name}") } - if $monit::service_manage_bool { + if $monit::service_manage { if $facts['osfamily'] == 'Debian' { file { '/etc/default/monit': content => $monit::default_file_content, diff --git a/templates/monitrc.erb b/templates/monitrc.erb index eac9509..6b8a8d6 100644 --- a/templates/monitrc.erb +++ b/templates/monitrc.erb @@ -40,8 +40,8 @@ set httpd port <%= @httpd_port %> and <%- end -%> <%- end -%> <%- if @mmonit_address -%> -set mmonit http<% if @mmonit_https_bool %>s<%- end -%>://<%= @mmonit_user %>:<%= @mmonit_password %>@<%= @mmonit_address %>:<%= @mmonit_port %>/collector -<%- if @mmonit_without_credential_bool -%> and register without credentials<%- end -%> +set mmonit http<% if @mmonit_https %>s<%- end -%>://<%= @mmonit_user %>:<%= @mmonit_password %>@<%= @mmonit_address %>:<%= @mmonit_port %>/collector +<%- if @mmonit_without_credential -%> and register without credentials<%- end -%> <%- end -%> include <%= @config_dir -%>/*