Module: Aws::Cfn::Stacker::Main
- Defined in:
- lib/aws/cfn/stacker/mixins/main.rb
Overview
noinspection ALL
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
-
#actors ⇒ Object
Returns the value of attribute actors.
-
#ALLACTIONS ⇒ Object
Returns the value of attribute ALLACTIONS.
-
#logger ⇒ Object
————————————————————————————————————–.
-
#LOGLEVELS ⇒ Object
Returns the value of attribute LOGLEVELS.
Class Method Summary collapse
-
.included(includer) ⇒ Object
————————————————————————————————————–.
Instance Method Summary collapse
-
#configure_application ⇒ Object
Parse configuration (options and config file).
- #configure_logging ⇒ Object
- #configure_stdout_logger ⇒ Object
-
#initialize ⇒ Object
——————————————————————————– Create a new instance of the current class configured for the given arguments and options.
-
#load_config_file(path = nil) ⇒ Object
Parse the config file.
-
#quiet_traps ⇒ Object
————————————————————————————————————–.
-
#reconfigure ⇒ Object
Reconfigure the application.
-
#run(argv) ⇒ Object
—————————————————————————–.
Instance Attribute Details
#actors ⇒ Object
Returns the value of attribute actors.
13 14 15 |
# File 'lib/aws/cfn/stacker/mixins/main.rb', line 13 def actors @actors end |
#ALLACTIONS ⇒ Object
Returns the value of attribute ALLACTIONS.
15 16 17 |
# File 'lib/aws/cfn/stacker/mixins/main.rb', line 15 def ALLACTIONS @ALLACTIONS end |
#logger ⇒ Object
12 13 14 |
# File 'lib/aws/cfn/stacker/mixins/main.rb', line 12 def logger @logger end |
#LOGLEVELS ⇒ Object
Returns the value of attribute LOGLEVELS.
14 15 16 |
# File 'lib/aws/cfn/stacker/mixins/main.rb', line 14 def LOGLEVELS @LOGLEVELS end |
Class Method Details
.included(includer) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# 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 |
Instance Method Details
#configure_application ⇒ Object
Parse configuration (options and config file)
116 117 118 119 |
# File 'lib/aws/cfn/stacker/mixins/main.rb', line 116 def configure_application (ARGV) load_config_file end |
#configure_logging ⇒ Object
175 176 177 178 179 180 181 182 183 |
# 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 ⇒ Object
185 186 |
# File 'lib/aws/cfn/stacker/mixins/main.rb', line 185 def configure_stdout_logger end |
#initialize ⇒ Object
Create a new instance of the current class configured for the given arguments and options
66 67 68 69 70 71 72 |
# File 'lib/aws/cfn/stacker/mixins/main.rb', line 66 def initialize() $STKR = self @TODO = {} @defaultOptions = {} @inis = [] super end |
#load_config_file(path = nil) ⇒ Object
Parse the config file
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# 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.("~"), '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 ⇒ Object
99 100 101 102 103 104 105 106 107 |
# 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 ⇒ Object
Reconfigure the application. You’ll want to override and super this method.
110 111 112 113 |
# File 'lib/aws/cfn/stacker/mixins/main.rb', line 110 def reconfigure configure_application configure_logging end |
#run(argv) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/aws/cfn/stacker/mixins/main.rb', line 75 def run(argv) begin StackerApplication.load_commands @argv = argv () quiet_traps() reconfigure() setup_application() run_application() # reportTODO(@args) exit 0 rescue StackerError => e puts e..light_red puts "#{__FILE__}:#{__LINE__} reraising ... " raise e exit -1 end end |