Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support htpasswd authentication #32

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ The following parameters are available in the `monit` class:
* [`httpd_allow`](#-monit--httpd_allow)
* [`httpd_user`](#-monit--httpd_user)
* [`httpd_password`](#-monit--httpd_password)
* [`httpd_htpasswd_file`](#-monit--httpd_htpasswd_file)
* [`httpd_htpasswd_crypto`](#-monit--httpd_htpasswd_crypto)
* [`httpd_htpasswd_users`](#-monit--httpd_htpasswd_users)
* [`logfile`](#-monit--logfile)
* [`mailserver`](#-monit--mailserver)
* [`mailformat`](#-monit--mailformat)
Expand Down Expand Up @@ -157,6 +160,30 @@ Specifies the password to access the Monit Dashboard. Default value: 'monit'

Default value: `$monit::params::httpd_password`

##### <a name="-monit--httpd_htpasswd_file"></a>`httpd_htpasswd_file`

Data type: `Optional[String]`

Specifies the path to the htpasswd file. Default value: ''

Default value: `$monit::params::httpd_htpasswd_file`

##### <a name="-monit--httpd_htpasswd_crypto"></a>`httpd_htpasswd_crypto`

Data type: `Optional[String]`

Specifies the encryption method in the htpasswd file. Default value: `md5`

Default value: `$monit::params::httpd_htpasswd_crypto`

##### <a name="-monit--httpd_htpasswd_users"></a>`httpd_htpasswd_users`

Data type: `Optional[Array]`

An array of users to be managed in the htpasswd file. Default value: []

Default value: `$monit::params::httpd_htpasswd_users`

##### <a name="-monit--logfile"></a>`logfile`

Data type: `Optional[String]`
Expand Down
12 changes: 12 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@
# @param httpd_password
# Specifies the password to access the Monit Dashboard. Default value: 'monit'
#
# @param httpd_htpasswd_file
# Specifies the path to the htpasswd file. Default value: ''
#
# @param httpd_htpasswd_crypto
# Specifies the encryption method in the htpasswd file. Default value: `md5`
#
# @param httpd_htpasswd_users
# An array of users to be managed in the htpasswd file. Default value: []
#
# @param logfile
# Specifies the logfile directive value. Default value: '/var/log/monit.log'
# It is possible to use syslog instead of direct file logging. (e.g. 'syslog facility log\_daemon')
Expand Down Expand Up @@ -114,6 +123,9 @@
String $httpd_allow = $monit::params::httpd_allow,
String $httpd_user = $monit::params::httpd_user,
String $httpd_password = $monit::params::httpd_password,
Optional[String] $httpd_htpasswd_file = $monit::params::httpd_htpasswd_file,
Optional[String] $httpd_htpasswd_crypto = $monit::params::httpd_htpasswd_crypto,
Optional[Array] $httpd_htpasswd_users = $monit::params::httpd_htpasswd_users,
Optional[String] $logfile = $monit::params::logfile,
Optional[String] $mailserver = $monit::params::mailserver,
Optional[Hash] $mailformat = $monit::params::mailformat,
Expand Down
3 changes: 3 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
$httpd_allow = '0.0.0.0/0.0.0.0'
$httpd_user = 'admin'
$httpd_password = 'monit'
$httpd_htpasswd_file = ''
$httpd_htpasswd_crypto = 'md5'
$httpd_htpasswd_users = []
$manage_firewall = false
$package_ensure = 'present'
$package_name = 'monit'
Expand Down
3 changes: 3 additions & 0 deletions templates/monitrc.erb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ set httpd port <%= @httpd_port %> and
allow <%= @httpd_user %>:"<%= @httpd_password %>"
<%- end -%>
<%- end -%>
<%- if !@httpd_htpasswd_crypto.empty? && !@httpd_htpasswd_file.empty? -%>
allow <%= @httpd_htpasswd_crypto %> <%= @httpd_htpasswd_file %> <%= @httpd_htpasswd_users.join(' ') %>
<%- end -%>
<%- end -%>
<%- if @mmonit_address -%>
set mmonit http<% if @mmonit_https %>s<%- end -%>://<%= @mmonit_user %>:<%= @mmonit_password %>@<%= @mmonit_address %>:<%= @mmonit_port %>/collector
Expand Down
Loading