From 97d050c91c47efec8cf2674049c78f15db0937dc Mon Sep 17 00:00:00 2001 From: monai Date: Tue, 17 May 2016 10:10:11 +0300 Subject: [PATCH 1/4] Add support for htpasswd authentication --- manifests/init.pp | 3 +++ manifests/params.pp | 3 +++ templates/monitrc.erb | 3 +++ 3 files changed, 9 insertions(+) diff --git a/manifests/init.pp b/manifests/init.pp index 36a5157..de7aa0b 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -5,6 +5,9 @@ $httpd_address = $monit::params::httpd_address, $httpd_user = $monit::params::httpd_user, $httpd_password = $monit::params::httpd_password, + $httpd_htpasswd_file = $monit::params::httpd_htpasswd_file, + $httpd_htpasswd_crypto = $monit::params::httpd_htpasswd_crypto, + $httpd_htpasswd_users = $monit::params::httpd_htpasswd_users, $manage_firewall = $monit::params::manage_firewall, $package_ensure = $monit::params::package_ensure, $package_name = $monit::params::package_name, diff --git a/manifests/params.pp b/manifests/params.pp index 8027b7d..4238667 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -8,6 +8,9 @@ $httpd_address = 'localhost' $httpd_user = 'admin' $httpd_password = 'monit' + $httpd_htpasswd_file = undef + $httpd_htpasswd_crypto = 'md5' + $httpd_htpasswd_users = [] $manage_firewall = false $package_ensure = 'present' $package_name = 'monit' diff --git a/templates/monitrc.erb b/templates/monitrc.erb index 5425aab..1f33c23 100644 --- a/templates/monitrc.erb +++ b/templates/monitrc.erb @@ -32,6 +32,9 @@ set httpd port <%= @httpd_port %> and <%- if !@httpd_user.empty? && !@httpd_password.empty? -%> allow <%= @httpd_user %>:<%= @httpd_password %> <%- end -%> + <%- if !@httpd_htpasswd_crypto.empty? && @httpd_htpasswd_file -%> + allow <%= @httpd_htpasswd_crypto %> <%= @httpd_htpasswd_file %> <%= @httpd_htpasswd_users.join(' ') %> + <%- end -%> <%- end -%> <%- if @mmonit_address -%> set mmonit http://<%= @mmonit_user %>:<%= @mmonit_password %>@<%= @mmonit_address %>:<%= @mmonit_port %>/collector From 7aaeb904892bd75b42cce9a99bf92e392a3107f4 Mon Sep 17 00:00:00 2001 From: monai Date: Tue, 17 May 2016 10:43:40 +0300 Subject: [PATCH 2/4] Add default value for $httpd_htpasswd_file --- manifests/params.pp | 2 +- templates/monitrc.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/params.pp b/manifests/params.pp index 4238667..2350df2 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -8,7 +8,7 @@ $httpd_address = 'localhost' $httpd_user = 'admin' $httpd_password = 'monit' - $httpd_htpasswd_file = undef + $httpd_htpasswd_file = '/etc/httpd/htpasswd' $httpd_htpasswd_crypto = 'md5' $httpd_htpasswd_users = [] $manage_firewall = false diff --git a/templates/monitrc.erb b/templates/monitrc.erb index 1f33c23..b045f39 100644 --- a/templates/monitrc.erb +++ b/templates/monitrc.erb @@ -32,7 +32,7 @@ set httpd port <%= @httpd_port %> and <%- if !@httpd_user.empty? && !@httpd_password.empty? -%> allow <%= @httpd_user %>:<%= @httpd_password %> <%- end -%> - <%- if !@httpd_htpasswd_crypto.empty? && @httpd_htpasswd_file -%> + <%- if !@httpd_htpasswd_crypto.empty? && !@httpd_htpasswd_file.empty? -%> allow <%= @httpd_htpasswd_crypto %> <%= @httpd_htpasswd_file %> <%= @httpd_htpasswd_users.join(' ') %> <%- end -%> <%- end -%> From 55bc11b4a607b789ebfcd38a1fa9252c7e57b645 Mon Sep 17 00:00:00 2001 From: monai Date: Tue, 17 May 2016 10:44:02 +0300 Subject: [PATCH 3/4] Validate httpd_htpasswd_* properties --- manifests/init.pp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/manifests/init.pp b/manifests/init.pp index de7aa0b..8649656 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -38,6 +38,9 @@ validate_string($httpd_address) validate_string($httpd_user) validate_string($httpd_password) + validate_string($httpd_htpasswd_file) + validate_string($httpd_htpasswd_crypto) + validate_array($httpd_htpasswd_users) validate_bool($manage_firewall) validate_string($package_ensure) validate_string($package_name) From 27fad21935bec5ffbc119608b20b98be1e4f2da6 Mon Sep 17 00:00:00 2001 From: monai Date: Fri, 20 May 2016 12:10:20 +0300 Subject: [PATCH 4/4] Require explicit htpasswd file param --- manifests/params.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/params.pp b/manifests/params.pp index 2350df2..f599814 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -8,7 +8,7 @@ $httpd_address = 'localhost' $httpd_user = 'admin' $httpd_password = 'monit' - $httpd_htpasswd_file = '/etc/httpd/htpasswd' + $httpd_htpasswd_file = '' $httpd_htpasswd_crypto = 'md5' $httpd_htpasswd_users = [] $manage_firewall = false