class PoiseMonit::MonitProviders::Base
The provider base class for `monit`.
@see PoiseMonit::Resources::PoiseMonit::Resource @provides monit
Public Instance Methods
The `enable` action for the `monit` resource.
@return [void]
# File lib/poise_monit/monit_providers/base.rb, line 56 def action_disable super notifying_block do uninstall_monit delete_directory delete_var_directory end end
The `enable` action for the `monit` resource.
@return [void]
# File lib/poise_monit/monit_providers/base.rb, line 35 def action_enable notifying_block do install_monit end # Split into two converges because we need to know what version is # installed to write the config in some cases. notifying_block do create_directory create_confd_directory create_var_directory create_events_directory # Only write out a state if we are actually going to use it. write_password_state if new_resource.httpd_port && new_resource.httpd_password write_config end super end
Return the path to the Monit binary. Must be implemented by subclasses.
@abstract @return [String]
# File lib/poise_monit/monit_providers/base.rb, line 69 def monit_binary raise NotImplementedError end
Private Instance Methods
Create the conf.d/ directory for Monit.
# File lib/poise_monit/monit_providers/base.rb, line 99 def create_confd_directory directory new_resource.confd_path do group new_resource.group mode '700' owner new_resource.owner end end
Create the configuration directory for Monit.
# File lib/poise_monit/monit_providers/base.rb, line 90 def create_directory directory new_resource.path do group new_resource.group mode '700' owner new_resource.owner end end
Create the events buffer directory.
# File lib/poise_monit/monit_providers/base.rb, line 118 def create_events_directory directory ::File.join(new_resource.var_path, 'events') do group new_resource.group mode '700' owner new_resource.owner end end
Create the /var/lib directory. This is used for the idfile, statefile, and events buffer.
# File lib/poise_monit/monit_providers/base.rb, line 109 def create_var_directory directory new_resource.var_path do group new_resource.group mode '700' owner new_resource.owner end end
Delete the configuration directory for Monit.
# File lib/poise_monit/monit_providers/base.rb, line 149 def delete_directory create_directory.tap do |r| r.action(:delete) r.recursive(true) end end
Delete the state directory for Monit.
# File lib/poise_monit/monit_providers/base.rb, line 157 def delete_var_directory create_var_directory.tap do |r| r.action(:delete) r.recursive(true) end end
Install Monit. Must be implemented by subclasses.
@abstract
# File lib/poise_monit/monit_providers/base.rb, line 78 def install_monit raise NotImplementedError end
Configure properties for Monit service resource.
# File lib/poise_monit/monit_providers/base.rb, line 165 def service_options(r) cmd = "#{monit_binary} -c #{new_resource.config_path} -I" cmd << " -d #{new_resource.daemon_interval}" unless new_resource.daemon_delay cmd << ' -v' if new_resource.daemon_verbose r.command(cmd) r.provider_no_auto('monit') r.user(new_resource.owner) end
Uninstall Monit. Must be implemented by subclasses.
@abstract
# File lib/poise_monit/monit_providers/base.rb, line 85 def uninstall_monit raise NotImplementedError end
Write the primary config file for Monit.
# File lib/poise_monit/monit_providers/base.rb, line 137 def write_config file new_resource.config_path do content new_resource.config_content group new_resource.group mode '600' notifies :reload, new_resource, :immediately owner new_resource.owner verify "#{monit_binary} -t -c #{Poise::Backports::VERIFY_PATH}" if defined?(verify) end end
Record the password for next time do we don't regenerate the config.
# File lib/poise_monit/monit_providers/base.rb, line 127 def write_password_state file new_resource.password_path do content new_resource.httpd_password group new_resource.group mode '600' owner new_resource.owner end end