class PoiseMonit::MonitProviders::Binaries

A `binaries` provider for `monit` to install from static binaries hosted at mmonit.com.

@see PoiseMonit::Resources::PoiseMonit::Resource @provides monit

Constants

MACHINE_ALIASES

Translation lookup for Chef/Ohai machine types vs. Monit packages.

Public Class Methods

provides_auto?(node, resource) click to toggle source

Allow anything we have a build for.

@api private

# File lib/poise_monit/monit_providers/binaries.rb, line 57
def self.provides_auto?(node, resource)
  static_machines.include?(static_machine_label(node))
end
static_machine_label(node, resource=nil) click to toggle source

Compute the machine label in the format Monit uses.

@api private

# File lib/poise_monit/monit_providers/binaries.rb, line 64
def self.static_machine_label(node, resource=nil)
  # Get the machine type in the format Monit uses.
  raw_machine = (node['kernel']['machine'] || 'unknown').downcase
  machine = MACHINE_ALIASES.fetch(raw_machine, raw_machine)

  # And then the OS type.
  raw_kernel = (node['kernel']['name'] || 'unknown').downcase
  kernel = case raw_kernel
  when 'aix'
    # Monit 5.16 and higher just use "aix". If we don't have a version,
    # assume it's going to be the latest version.
    if !resource || !resource.version  || ::Gem::Version.create(resource.version) >= ::Gem::Version.create('5.16')
      'aix'
    # Less correct than "aix#{node['kernel']['version']}.#{node['kernel']['release']}"
    # but more likely to work on more systems. Notably we think the 6.1
    # build should work on AIX 7 just fine.
    elsif node['kernel']['version'].to_i <= 5
      'aix5.3'
    else
      'aix6.1'
    end
  when 'sunos'
    'solaris'
  when 'darwin'
    # Short circuit, because we don't care about the machine type.
    return 'macosx-universal'
  else
    raw_kernel
  end

  # Put 'em together.
  "#{kernel}-#{machine}"
end

Public Instance Methods

monit_binary() click to toggle source

(see Base#monit_binary)

# File lib/poise_monit/monit_providers/binaries.rb, line 99
def monit_binary
  ::File.join(static_folder, 'bin', 'monit')
end

Private Instance Methods

install_monit() click to toggle source

(see Base#install_monit)

# File lib/poise_monit/monit_providers/binaries.rb, line 106
def install_monit
  install_static
end
uninstall_monit() click to toggle source

(see Base#uninstall_monit)

# File lib/poise_monit/monit_providers/binaries.rb, line 111
def uninstall_monit
  uninstall_static
end