Module: App
- Defined in:
- lib/awx.rb,
lib/aws/aws.rb,
lib/core/opt.rb,
lib/aws/aws_cli.rb,
lib/core/stacks.rb,
lib/aws/aws_cache.rb,
lib/core/replacer.rb,
lib/aws/aws_profile.rb,
lib/aws/aws_reports.rb,
lib/aws/aws_outputter.rb,
lib/aws/aws_validator.rb,
lib/aws/aws_credentials.rb,
lib/aws/aws_cloudformation.rb
Defined Under Namespace
Classes: AWS, AWSCli, AWSCloudFormation, AWSCredentials, AWSOutputter, AWSProfile, AWSReports, AWSValidator, Cache, CacheKey, Opt, Replacer, Stacks
Constant Summary collapse
- GEM_NAME =
'awx'
- SCHEMA_FILE =
"#{App::Opt::get_base_path}#{App::Opt::OPT_PATH}/config/schema.yml"
- TEMPLATE_FILE =
"#{App::Opt::get_base_path}#{App::Opt::OPT_PATH}/config/template.yml"
- CONFIG_FILE =
'~/.awx.yml'
- SECRET =
'gts8cxeCn1EkzxH3ASXwnz7nboOnf6AjnQhqdjQp8kzxH7q7Ne'
Class Method Summary collapse
- .execute ⇒ Object
-
.is_albert_mac ⇒ Object
Very hacky code that looks in the configuration file for a key/pair value and if exists, returns true.
Class Method Details
.execute ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 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 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
# File 'lib/awx.rb', line 23 def self.execute begin unless ARGV[0] == 'config' || ARGV[0] == 'x' Blufin::Config::init(SCHEMA_FILE, TEMPLATE_FILE, CONFIG_FILE, GEM_NAME) App::AWSProfile::init(Blufin::Config::get) end profile = App::AWSProfile::get_profile Convoy::App.create do |awx| awx.version AWX_VERSION awx.summary <<TEMPLATE \x1B[48;5;130m\x1B[38;5;255m AWX \x1B[0m\x1B[0m \x1B[38;5;130m\xe2\x80\x94 Amazon Web-Services X️-Tender\x1B[38;5;248m _____ __ ______ ___ / _ \\/ \\ / \\ \\/ / / /_\\ \\ \\/\\/ /\\ / / | \\ / / \\ \\____|__ /\\__/\\ / /___/\\ \\ \\/ \\/ \\_/\x1B[0m TEMPLATE awx.description 'An abstraction layer built around the AWS-cli (written by: Albert Rannetsperger)' # c - CLOUD FORMATION if ARGV[0] != 'setup' && ARGV[0] != 'x' && profile.has_key?(App::AWSProfile::CLOUDFORMATION) awx.command :cloudformation, :aliases => [:c] do |awx_cloudformation| awx_cloudformation.summary 'Create, list and delete cloud-formation stacks' # c - CLOUD FORMATION CREATE awx_cloudformation.command :create, :aliases => [:c] do |awx_cloudformation_create| awx_cloudformation_create.summary 'Create stack' awx_cloudformation_create. do |opts| opts.opt :clear_cache, 'Clear cache', :short => '-c', :long => '--clear-cache', :type => :boolean opts.opt :rerun, "Re-run previous with cached values (if exists) \xe2\x80\x94 #{Blufin::Terminal::format_invalid('@NotImplemented')}", :short => '-r', :long => '--re-run', :type => :boolean if Blufin::Files::path_exists("#{File.(App::AWSCloudFormation::get_cloudformation_path)}/test") opts.opt :test, 'Run through test-template.', :short => '-t', :long => '--test', :type => :boolean end end awx_cloudformation_create.action do |opts, args| AppCommand::CloudFormationCreate.new(opts, args).execute end end # d - CLOUD FORMATION DETECT-DRIFT awx_cloudformation.command :detect_drift, :aliases => [:d] do |awx_cloudformation_detect_drift| awx_cloudformation_detect_drift.summary 'Detect drift (currently for all stacks)' awx_cloudformation_detect_drift.action do |opts, args| AppCommand::CloudFormationDetectDrift.new(opts, args).execute end end # D - CLOUD FORMATION DELETE awx_cloudformation.command :delete, :aliases => [:D] do |awx_cloudformation_delete| awx_cloudformation_delete.summary 'Delete stack' awx_cloudformation_delete.action do |opts, args| AppCommand::CloudFormationDelete.new(opts, args).execute end end awx_cloudformation.action do system("#{App::GEM_NAME} c -h") end end end # d - DYNAMO-DB if ARGV[0] != 'setup' && ARGV[0] != 'x' && Blufin::Config::get.has_key?('DynamoDBPath') awx.command :dynamodb, :aliases => [:d] do |dynamodb| dynamodb.summary 'Run a local instance of DynamoDB' dynamodb.action do |opts, args| AppCommand::DynamoDB.new(opts, args).execute end end end # d - DEPLOY (DEPRECATED) if ARGV[0] != 'setup' && ARGV[0] != 'x' && (profile.has_key?('Projects')) awx.command :deploy_deprecated, :aliases => [:d] do |deploy_deprecated| deploy_deprecated.summary "Deploy application(s) to AWS #{Blufin::Terminal::format_invalid('@deprecated')}" deploy_deprecated. do |opts| opts.opt :skip_build, 'Skip build', :short => '-S', :long => '--skip-build', :type => :boolean end deploy_deprecated.action do |opts, args| AppCommand::DeployDeprecated.new(opts, args).execute end end end # i - INFRASTRUCTURE if ARGV[0] != 'setup' && ARGV[0] != 'x' && (profile.has_key?(App::AWSProfile::PROJECTS)) && (profile.has_key?(App::AWSProfile::STACKS)) awx.command :infrastructure, :aliases => [:i] do |infrastructure| infrastructure.summary 'View, modify & deploy application(s) to pre-defined infrastructure' infrastructure.action do |opts, args| AppCommand::Infrastructure.new(opts, args).execute end end end # l - LIST awx.command :list, :aliases => [:l] do |awx_list| awx_list.summary 'List AWS instances/resources' awx_list. do |opts| opts.opt :json, 'Return data as JSON', :short => '-j', :long => '--json', :type => :boolean opts.opt :json_prompt, 'Return data as JSON (for Terminal::prompt)', :short => '-J', :long => '--json-prompt', :type => :boolean opts.opt :yaml, 'Return data as Yaml', :short => '-y', :long => '--yaml', :type => :boolean opts.opt :yaml_colored, 'Return data as Yaml (colored)', :short => '-Y', :long => '--yaml-colored', :type => :boolean opts.opt :resource, "Specify a resource. For all resources type: #{Blufin::Terminal::format_command('all')}", :short => '-r', :long => '--resource', :type => :string opts.opt :verbose, 'Output the original response from AWS (with all fields).', :short => '-v', :long => '--verbose', :type => :boolean opts.opt :metadata, 'Output the YML definition file metadata.', :short => '-m', :long => '--metadata', :type => :boolean # TODO - Implement Region + Project filtering (possibly more). opts.opt :region, "Specify a region \xe2\x80\x94 #{Blufin::Terminal::format_invalid('@NotImplemented')}", :short => '-R', :long => '--region', :type => :string opts.opt :environment, "Specify a environment \xe2\x80\x94 #{Blufin::Terminal::format_invalid('@NotImplemented')}", :short => '-e', :long => '--environment', :type => :string opts.opt :project, "Specify a project \xe2\x80\x94 #{Blufin::Terminal::format_invalid('@NotImplemented')}", :short => '-p', :long => '--project', :type => :string end awx_list.action do |opts, args| AppCommand::List.new(opts, args).execute end end # s - SSH awx.command :ssh, :aliases => [:s] do |ssh| ssh.summary 'SSH into EC2 instances' ssh.action do |opts, args| AppCommand::SSH.new(opts, args).execute end end # S - SWITCH if ARGV[0] != 'setup' && ARGV[0] != 'x' && App::AWSProfile::get_profile_names.length > 1 && !App::AWSProfile::get_credentials.nil? # Only show if we have multiple profiles. awx.command :switch, :aliases => [:S] do |switch| switch.summary 'Switch Profiles' switch.action do |opts, args| AppCommand::Switch.new(opts, args).execute end end end # u - UPLOAD if ARGV[0] != 'setup' && ARGV[0] != 'x' && ( (profile.has_key?(App::AWSProfile::STACKS) && profile[App::AWSProfile::STACKS].has_key?('Local')) || (profile.has_key?(App::AWSProfile::PROJECTS) && profile[App::AWSProfile::PROJECTS].has_key?('Local')) || (profile.has_key?(App::AWSProfile::CLOUDFORMATION) && profile[App::AWSProfile::CLOUDFORMATION]['Templates'].has_key?('Local'))) awx.command :upload, :aliases => [:u] do |upload| upload.summary 'Upload configuration(s) to S3' # d - UPLOAD STACKS if profile.has_key?(App::AWSProfile::STACKS) && profile[App::AWSProfile::STACKS].has_key?('Local') upload.command :stacks, :aliases => [:s] do |upload_stacks| upload_stacks.summary 'Upload Stacks' upload_stacks.action do |opts, args| args = args.unshift(AppCommand::Upload::STACKS) AppCommand::Upload.new(opts, args).execute end end end # p - UPLOAD PROJECTS if profile.has_key?(App::AWSProfile::PROJECTS) && profile[App::AWSProfile::PROJECTS].has_key?('Local') upload.command :projects, :aliases => [:p] do |upload_projects| upload_projects.summary 'Upload Projects' upload_projects.action do |opts, args| args = args.unshift(App::AWSProfile::PROJECTS) AppCommand::Upload.new(opts, args).execute end end end # t - UPLOAD TEMPLATES if profile.has_key?(App::AWSProfile::CLOUDFORMATION) && profile[App::AWSProfile::CLOUDFORMATION]['Templates'].has_key?('Local') upload.command :templates, :aliases => [:t] do |upload_templates| upload_templates.summary 'Upload Templates' upload_templates.action do |opts, args| args = args.unshift(AppCommand::Upload::TEMPLATES) AppCommand::Upload.new(opts, args).execute end end end upload.action do system("#{App::GEM_NAME} u -h") end end end # x - CONFIG awx.command :config, :aliases => [:x] do |config| config.summary 'Setup your configuration file' config.action do Blufin::Config::edit_config(App::CONFIG_FILE) end end # awx - DEFAULT awx.action do system("#{App::GEM_NAME} -h") end end rescue RuntimeError => e Blufin::Terminal::print_exception(e); end end |
.is_albert_mac ⇒ Object
Very hacky code that looks in the configuration file for a key/pair value and if exists, returns true.
228 229 230 231 232 233 |
# File 'lib/awx.rb', line 228 def self.is_albert_mac if Blufin::Config::get.has_key?('CustomOptions') && Blufin::Config::get['CustomOptions'].has_key?('Secret') return Blufin::Config::get['CustomOptions']['Secret'] == SECRET end false end |