Search code examples
chef-inframonitoringchef-solomonit

Monit Web Service(HTTPD) not available


I'm trying to configure monit on my server using chef solo and the monit cookbook. When I visit port 2812 response saying this webpage is not available. This only when access remotely via a web browser. I get the expected content when curling locally.

monit cookbook

include_recipe 'monit'

cookbook_file '/etc/monit/conf.d/puma.conf' do
  source 'monit-puma'
  owner 'deploy'
  group 'deploy'
  mode '0755'
  action :create
end

cookbook_file '/etc/monit/conf.d/nginx.conf' do
  source 'monit-nginx'
  owner 'deploy'
  group 'deploy'
  mode '0755'
  action :create
end

execute 'sudo monit reload'

/etc/monit/conf.d/compat.conf

set httpd port 2812
  use address 127.0.0.1
  allow admin:mybestpassword

default attributes

default['monit']['port'] = '2812'
default['monit']['username'] = 'admin'
default['monit']['password'] = '...'
default['monit']['address'] = '0.0.0.0'
default['monit']['allow'] = ['0.0.0.0']

poise-monit UPDATE

monit 'monit' do
  daemon_interval 30
  event_slots 1000
  httpd_port 2812
  httpd_username 'admin'
  httpd_password 'Password1'
  group 'deploy'
end

poise-monit recipe

monit 'monit' do
  daemon_interval 30
  event_slots 1000
  httpd_port 2812
  httpd_username 'admin'
  httpd_password 'Password1'
  group 'deploy'
end


monit_config 'nginx' do
  source 'monit_nginx.conf.erb'
end


monit_config 'puma' do
  source 'monit-puma.conf.erb'
end

poise-monit generates /etc/monit/monitrc

# Generated by Chef for monit[monit]

SET PIDFILE /var/run/monit_real.pid

SET LOGFILE /var/log/monit.log

SET IDFILE /var/lib/monit/id
SET STATEFILE /var/lib/monit/state
SET EVENTQUEUE BASEDIR /var/lib/monit/events SLOTS 1000

SET HTTPD PORT 2812
  ALLOW admin:Password1

INCLUDE /etc/monit/conf.d/*

Solution

  • As stated in the README, you need to either set a password or allow settings for the node attributes to be used. Otherwise they are ignored for safety. You can check out the poise-monit documentation for more detailed instructions on configuring the web UI.