class MU::Groomer

Plugins under this namespace serve as interfaces to configuration management tools (Chef, Puppet, etc).

Plugins under this namespace serve as interfaces to host configuration management tools, like Ansible or Puppet.

Plugins under this namespace serve as interfaces to host configuration management tools, like Chef or Puppet.

Attributes

groomer_class[R]
groomer_obj[R]

Public Class Methods

availableGroomers() click to toggle source

List of known/supported groomers which are installed and appear to be working @return [Array<String>]

# File modules/mu/groomer.rb, line 35
def self.availableGroomers
  available = []
  MU::Groomer.supportedGroomers.each { |groomer|
    begin
      groomerbase = loadGroomer(groomer)
      available << groomer if groomerbase.available?
    rescue LoadError
    end
  }

  available
end
loadGroomer(groomer) click to toggle source

@param groomer [String]: The grooming agent to load. @return [Class]: The class object implementing this groomer agent

# File modules/mu/groomer.rb, line 66
def self.loadGroomer(groomer)
  return nil if !groomer
  if !File.size?(MU.myRoot+"/modules/mu/groomers/#{groomer.downcase}.rb")
    raise MuError, "Requested to use unsupported grooming agent #{groomer}"
  end
  begin
  require "mu/groomers/#{groomer.downcase}"
    myclass = Object.const_get("MU").const_get("Groomer").const_get(groomer)
  rescue NameError
    raise MuError, "No groomer available named '#{groomer}' - valid values (case-sensitive) are: #{MU.supportedGroomers.join(", ")})"
  end
  MU::Groomer.requiredMethods.each { |method|
    if !myclass.public_instance_methods.include?(method)
      raise MuError, "MU::Groom::#{groomer} has not implemented required instance method #{method}"
    end
  }
  MU::Groomer.requiredClassMethods.each { |method|
    if !myclass.respond_to?(method)
      raise MuError, "#{myclass} doesn't implement #{method}"
    end
  }

  return myclass
end
new(server) click to toggle source

@param server [MU::Cloud::Server]: The server which this groomer will be configuring.

# File modules/mu/groomer.rb, line 95
def initialize(server)
  @server = server
  if !server.config.has_key?("groomer")
    @groomer_class = MU::Groomer.loadGroomer(MU::Config.defaultGroomer)
  else
    @groomer_class = MU::Groomer.loadGroomer(server.config['groomer'])
  end
  @groom_semaphore = Mutex.new
  @groom_locks = {}
  @groomer_obj = @groomer_class.new(server)
end
requiredClassMethods() click to toggle source

Class methods that any Groomer plugin must implement

# File modules/mu/groomer.rb, line 54
def self.requiredClassMethods
  [:getSecret, :cleanup, :saveSecret, :deleteSecret, :available?]
end
requiredMethods() click to toggle source

Instance methods that any Groomer plugin must implement

# File modules/mu/groomer.rb, line 49
def self.requiredMethods
  [:preClean, :bootstrap, :haveBootstrapped?, :run, :saveDeployData, :getSecret, :saveSecret, :deleteSecret, :reinstall]
end
supportedGroomers() click to toggle source

List of known/supported grooming agents (configuration management tools)

# File modules/mu/groomer.rb, line 29
def self.supportedGroomers
  ["Chef", "Ansible"]
end

Public Instance Methods

cleanup() click to toggle source

Wrapper for Groomer implementations of the cleanup class method. We'll helpfully provide the arguments we know the answer to.

# File modules/mu/groomer.rb, line 109
def cleanup
  raise MuError, "Called MU::Groomer.cleanup, but I don't have an instantiated server object to clean!" if @server.nil?
  @groomer_class.cleanup(@server.mu_name, @server.config['vault_access'])
end