module Aws::Cfn::Stacker::Main
noinspection ALL
Attributes
ALLACTIONS[RW]
LOGLEVELS[RW]
actors[RW]
logger[RW]
Public Class Methods
included(includer)
click to toggle source
# File lib/aws/cfn/stacker/mixins/main.rb, line 48 def self.included(includer) includer.extend(ClassMethods) includer.class_eval do requires do require 'colorize' require 'inifile' require 'awesome_print' end self.actors = {} self.loglevels = [:trace, :debug, :step, :info, :warn, :error, :fatal, :todo] self.allactions = [ :build, :configure, :create, :status, :update, :delete, :outputs, :watch, :list_params, :list_stacks ] end end
new()
click to toggle source
Create a new instance of the current class configured for the given arguments and options
Calls superclass method
# File lib/aws/cfn/stacker/mixins/main.rb, line 66 def initialize() $STKR = self @TODO = {} @defaultOptions = {} @inis = [] super end
Public Instance Methods
configure_application()
click to toggle source
Parse configuration (options and config file)
# File lib/aws/cfn/stacker/mixins/main.rb, line 116 def configure_application parse_options(ARGV) load_config_file end
configure_logging()
click to toggle source
# File lib/aws/cfn/stacker/mixins/main.rb, line 175 def configure_logging @config[:log_opts] = lambda{|mlll| { :pattern => "%#{mlll}l: %m %C\n", :date_pattern => '%Y-%m-%d %H:%M:%S', } } @logger = getLogger(@config) end
configure_stdout_logger()
click to toggle source
# File lib/aws/cfn/stacker/mixins/main.rb, line 185 def configure_stdout_logger end
load_config_file(path=nil)
click to toggle source
Parse the config file
# File lib/aws/cfn/stacker/mixins/main.rb, line 124 def load_config_file(path=nil) <<-EOC Loads config files from a given path, or additional paths if not specified. If a specific path isn't specified, loads the following locations: - $CWD/config/config.ini - $HOME/.stacker/config.ini - /etc/stacker/config.ini - /usr/local/etc/stacker/config.ini Establishes default values for a handful of section variables: - disable_rollback = 'true' - don't automatically rollback on error - s3_bucket = 'amplify-sto-templates' - s3 bucket to upload templates to if needed. - cf_template_dir = $CWD/templates - location of CloudFormation templates - stack_dir = $CWD/stacks - location where stack config directories are stored - playbooks_dir = $CWD/ansible/playbooks EOC cwd = Dir.getwd() defaults={ disable_rollback: true, template_dir: File.join(cwd, 'templates'), stack_dir: File.join(File.dirname(@config[:config_file]), 'stacks'), playbooks_dir: File.join(cwd, 'ansible', 'playbooks') } #config = ConfigParser.ConfigParser( paths = [ File.join(cwd,'config', 'config.ini'), File.join(File.expand_path("~"), 'config.ini'), '/etc/stacker/config.ini', '/usr/local/etc/stacker/config.ini', ] if path paths.unshift path end config = nil paths.each do |path| begin config = IniFile.load(path) @inis << path break rescue => e # noop end end return config end
quiet_traps()
click to toggle source
# File lib/aws/cfn/stacker/mixins/main.rb, line 99 def quiet_traps trap("TERM") do exit 1 end trap("INT") do exit 2 end end
reconfigure()
click to toggle source
Reconfigure the application. You’ll want to override and super this method.
# File lib/aws/cfn/stacker/mixins/main.rb, line 110 def reconfigure configure_application configure_logging end
run(argv)
click to toggle source
# File lib/aws/cfn/stacker/mixins/main.rb, line 75 def run(argv) begin StackerApplication.load_commands @argv = argv prescreen_options() quiet_traps() reconfigure() setup_application() run_application() # reportTODO(@args) exit 0 rescue StackerError => e puts e.message.light_red puts "#{__FILE__}:#{__LINE__} reraising ... " raise e exit -1 end end