diff --git a/manifests/init.pp b/manifests/init.pp index d810afc..8051cc3 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -49,7 +49,7 @@ monit::sshdcheck { "sshdcheck_${fqdn}": } } -define monit::options ($interval, $mailserver, $email, $http_address, $http_allow, $http_user, $http_password) { +define monit::options ($interval = 180, $mailserver = undef, $email = undef, $http_address = undef, $http_allow = undef, $http_user = undef, $http_password = undef) { file { "/etc/monit/conf.d/options_$name": mode => 600, owner => root, diff --git a/templates/options.erb b/templates/options.erb index 8fe578e..600ded1 100644 --- a/templates/options.erb +++ b/templates/options.erb @@ -3,24 +3,22 @@ # # check services interval -<% if has_variable?("interval") then %> -set daemon <%= interval %> -<% else %> -set daemon 180 +<% if @interval then %> +set daemon <%= @interval %> <% end %> -<% if has_variable?("mailserver") then %> -set mailserver <%= mailserver %> +<% if @mailserver then %> +set mailserver <%= @mailserver %> <% end %> -<% if has_variable?("email") then %> -set alert <%= email %> +<% if @email then %> +set alert <%= @email %> <% end %> -<% if has_variable?("http_address") and has_variable?("http_allow") and has_variable?("http_user") and has_variable?("http_password") then %> +<% if @http_address and @http_allow and @http_user and @http_password then %> set httpd port 2812 and - use address <%= http_address %> - allow <%= http_allow %> - allow <%= http_user %>:<%= http_password %> + use address <%= @http_address %> + allow <%= @http_allow %> + allow <%= @http_user %>:<%= @http_password %> <% end %>