Module: App
- Defined in:
- lib/awx.rb,
lib/aws/aws.rb,
lib/core/opt.rb,
lib/aws/aws_cli.rb,
lib/aws/aws_cache.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
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 |
# 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 Convoy::App.create do |awx| awx.version AWX_VERSION awx.summary " \\x1B[48;5;130m\\x1B[38;5;255m AWX \\x1B[0m\\x1B[0m \\x1B[38;5;130m\\xe2\\x80\\x94 Amazon Web-Services X\uFE0F-Tender\\x1B[38;5;248m\n\n _____ __ ______ ___\n / _ \\\\/ \\\\ / \\\\ \\\\/ /\n / /_\\\\ \\\\ \\\\/\\\\/ /\\\\ /\n/ | \\\\ / / \\\\\n\\\\____|__ /\\\\__/\\\\ / /___/\\\\ \\\\\n \\\\/ \\\\/ \\\\_/\\x1B[0m\n" awx.description 'An abstraction layer built around the AWS-cli (written by: Albert Rannetsperger)' # c - AWS CLOUD FORMATION if ARGV[0] != 'setup' && ARGV[0] != 'x' && App::AWSProfile::get_profile.has_key?('CloudFormation') awx.command :cloudformation, :aliases => [:c] do |awx_cloudformation| awx_cloudformation.summary 'Create, list and delete cloud-formation stacks' # c - AWS CLOUD FORMATION CREATE awx_cloudformation.command :create, :aliases => [:c] do |awx_cloudformation_create| awx_cloudformation_create.summary 'Create stack' awx_cloudformation_create. do |opts| if Blufin::Files::path_exists("#{File.expand_path(App::AWSProfile::get_profile['CloudFormation']['TemplatePath'])}/test") opts.opt :test, 'Run through test-template.', :short => '-t', :long => '--test', :type => :boolean end opts.opt :test, "Re-run previous with cached values (if exists) \xe2\x80\x94 #{Blufin::Terminal::format_invalid('@NotImplemented')}", :short => '-R', :long => '--re-run', :type => :boolean end awx_cloudformation_create.action do |opts, args| AppCommand::AWSCloudFormationCreate.new(opts, args).execute end end # d - AWS 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::AWSCloudFormationDetectDrift.new(opts, args).execute end end # D - AWS 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::AWSCloudFormationDelete.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 => [:db] do |db| db.summary 'Run a local instance of DynamoDB' db.action do |opts, args| AppCommand::AWSDynamoDB.new(opts, args).execute end end end # D - DEPLOY if ARGV[0] != 'setup' && ARGV[0] != 'x' && (App::AWSProfile::get_profile.has_key?('Projects')) awx.command :deploy, :aliases => [:D] do |deploy| deploy.summary 'Deploy application(s) to AWS' deploy. do |opts| opts.opt :skip_build, 'Skip build', :short => '-S', :long => '--skip-build', :type => :boolean end deploy.action do |opts, args| AppCommand::AWSDeploy.new(opts, args).execute end end end # l - AWS 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::AWSList.new(opts, args).execute end end # s - SWITCH if ARGV[0] != 'setup' && ARGV[0] != 'x' && App::AWSProfile::get_profile_names.length > 1 # Only show if we have multiple profiles. awx.command :switch, :aliases => [:s] do |switch| switch.summary 'Switch Profiles' switch.action do |opts, args| AppCommand::AWSSwitch.new(opts, args).execute 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.
164 165 166 167 168 169 |
# File 'lib/awx.rb', line 164 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 |