class Elevage::Build
Create new platform definition files and environments folder structure, used by the command line `build` option
Public Class Methods
source_root()
click to toggle source
rubocop:enable LineLength
# File lib/elevage/build.rb, line 34 def self.source_root File.dirname(__FILE__) end
Public Instance Methods
build()
click to toggle source
Process and execute the `build` command
# File lib/elevage/build.rb, line 41 def build # Make the logfile directory if it doesn't exist Dir.mkdir(options[:logfiles]) unless Dir.exist?(options[:logfiles]) # Fetch the environment and make sure it passes basic health checks @environment = Elevage::Environment.new(env) fail(IOError) unless @environment.healthy? # ============================================================= # Option sanity checking. # # What are we going to reject as invalid options? # if options[:all] && options[:tier] || options[:all] && options[:component] || options[:tier] && options[:component] warn 'The --all, --tier and --component options may not be specified together.' exit false end if options[:node] && !options[:component] warn 'When requesting a --node you must specify which --component.' exit false end unless options[:all] || options[:tier] || options[:component] warn 'You must specify one of --all, --tier=<tier>, or --component=<component>' exit false end # Determine what, exactly, we're supposed to build if options[:all] # ============================================================= # Build ALL THE THINGS! # @environment.provision(type: :all, options: options) elsif options[:tier] # ============================================================= # Build most of the things... # if options[:tier].eql?('tier') warn 'Was asked to build a tier, but was not told which one!' exit false end @environment.provision(type: :tier, tier: options[:tier], options: options) elsif options[:component] # ============================================================= # Build a few things... # if options[:component].eql?('component') warn 'Was asked to build a component, but was not told which one!' exit false end # See if we're actually only supposed to build just one thing... if options[:node] @environment.provision(type: :node, component: options[:component], instance: options[:node], options: options) else @environment.provision(type: :component, component: options[:component], options: options) end end end