module Environmate

Constants

VERSION

Public Class Methods

configuration() click to toggle source
# File lib/environmate/configuration.rb, line 23
def self.configuration
  @configuration
end
load_configuration(environment, config_file = nil) click to toggle source
# File lib/environmate/configuration.rb, line 8
def self.load_configuration(environment, config_file = nil)
  config_file ||= config_location
  if config_file.nil?
    raise "No configuration file was provided"
  end
  unless File.exists?(config_file)
    raise "Configuration file #{config_file} does not exist"
  end
  config = YAML.load_file(config_file)
  if config[environment].nil?
    raise "No configuration for environment '#{environment}' found in file #{config_file}"
  end
  @configuration = config_defaults.merge(config[environment])
end
log() click to toggle source
# File lib/environmate/log.rb, line 8
def self.log
  @log ||= Logger.new(STDOUT)
end
logger=(logger) click to toggle source
# File lib/environmate/log.rb, line 12
def self.logger=(logger)
  @log = logger
end

Private Class Methods

config_defaults() click to toggle source
# File lib/environmate/configuration.rb, line 29
def self.config_defaults
  {
    'logfile'                     => '/var/log/enviromate.log',
    'loglevel'                    => 'WARN',
    'environment_path'            => '/etc/puppetlabs/code/environments',
    'lockfile_path'               => '/var/run/lock/environmate',
    'lockfile_options'            => {
      'timeout' => 300
    },
    'master_repository'           => 'http://gitlab.example.com/puppet/control',
    'master_branch'               => 'origin/master',
    'master_path'                 => '/etc/puppetlabs/code/environmate',
    'dynamic_environments_prefix' => 'env/',
    'static_environments'         => {},
    'install_modules_command'     => 'librarian-puppet install --destructive',
    'server_settings'             => {},
  }
end
config_location() click to toggle source
# File lib/environmate/configuration.rb, line 48
def self.config_location
  [
    '/etc/environmate.yml',
    File.expand_path('~/.environmate.yml'),
  ].find{|c| File.exist?(c)}
end