awx 0.6.8 → 0.6.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/aws/aws_cli.rb +2 -2
- data/lib/aws/aws_profile.rb +4 -2
- data/lib/awx.rb +28 -13
- data/lib/routes/cloudformation_create.rb +7 -4
- data/lib/routes/upload.rb +50 -7
- data/lib/version.rb +1 -1
- data/opt/config/schema.yml +2 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 16021b5064f0049ca45a3b69fdf7dabc825b2dad
|
4
|
+
data.tar.gz: 474f2e36b2c3ee7e025f31baa95772712feab355
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e1bc9ede728cb476302200bc63d547a2c3cd37310b16aa349502f5bb980e1f551b47a0732b6be360c407a9d33f556f0584c48931bed46e9099cca63223f2a91
|
7
|
+
data.tar.gz: 26b34761934c99f5ba5c0ad3503893e5905938f0b06fab463d6a57c0cbebb82b3c5171292e99fb9d0b927db6f1c74804bbee11fbc0d3ec2e62d3cdcc75d668fb
|
data/lib/aws/aws_cli.rb
CHANGED
@@ -66,7 +66,7 @@ module App
|
|
66
66
|
|
67
67
|
# Create a CloudFormation Stack.
|
68
68
|
# @return string (StackID)
|
69
|
-
def self.cloudformation_stack_create(region, stack_name, s3_url, params: nil, tags: nil, capabilities: [], term_protect: false, term_script: false, timeout: nil)
|
69
|
+
def self.cloudformation_stack_create(region, stack_name, s3_url, params: nil, tags: nil, capabilities: [], term_protect: false, term_script: false, timeout: nil, open_chrome: true)
|
70
70
|
params = params.nil? ? '' : " --parameters '#{params.gsub("'", "\\'")}'"
|
71
71
|
tags = tags.nil? ? '' : " --tags '#{tags.gsub("'", "\\'")}'"
|
72
72
|
capabilities = !capabilities.any? ? '' : " --capabilities #{capabilities.join(' ')}"
|
@@ -80,7 +80,7 @@ module App
|
|
80
80
|
if stack_send.has_key?('StackId')
|
81
81
|
Blufin::Terminal::success('Template was accepted by AWS.', ["\x1B[38;5;240mStackId \xe2\x80\x94 \x1B[38;5;40m#{stack_send['StackId']}"])
|
82
82
|
stack_url = "https://#{region}.console.aws.amazon.com/cloudformation/home?region=#{region}#/stacks?filter=active&tab=events&stackId=#{URI::encode(stack_send['StackId'])}"
|
83
|
-
system("/usr/bin/open -a '/Applications/Google Chrome.app' '#{stack_url}'")
|
83
|
+
system("/usr/bin/open -a '/Applications/Google Chrome.app' '#{stack_url}'") if open_chrome
|
84
84
|
else
|
85
85
|
Blufin::Terminal::error("Key not found in response: #{Blufin::Terminal::format_invalid('StackId')}", stack_send.inspect, true)
|
86
86
|
end
|
data/lib/aws/aws_profile.rb
CHANGED
@@ -14,6 +14,8 @@ module App
|
|
14
14
|
PROFILES = 'Profiles'
|
15
15
|
CLOUDFORMATION = 'CloudFormation'
|
16
16
|
SSH_KEYS = 'SSHKeys'
|
17
|
+
PROJECTS = 'Projects'
|
18
|
+
DEPLOYMENTS = 'Deployments'
|
17
19
|
|
18
20
|
# Reads the config data and decides what profile to use.
|
19
21
|
# @return void
|
@@ -55,8 +57,8 @@ module App
|
|
55
57
|
cloudformation_template_path = @@profile[CLOUDFORMATION]['Templates']['Local']['Path']
|
56
58
|
errors << "Path not found: #{Blufin::Terminal::format_invalid(cloudformation_template_path)}" unless Blufin::Files::path_exists(cloudformation_template_path)
|
57
59
|
end
|
58
|
-
s3_region
|
59
|
-
default_regions
|
60
|
+
s3_region = @@profile[CLOUDFORMATION]['Uploads']['S3Bucket']['Region']
|
61
|
+
default_regions = @@profile[CLOUDFORMATION]['Defaults']['Regions']
|
60
62
|
errors << "Invalid region: #{Blufin::Terminal::format_invalid(s3_region)}" unless App::AWS::VALID_REGIONS.include?(s3_region)
|
61
63
|
errors << "Need atleast 1 default region for: #{Blufin::Terminal::format_invalid('Profiles[].CloudFormation.Defaults.Regions')}" if default_regions.nil? || !default_regions.any?
|
62
64
|
default_regions.each do |default_region|
|
data/lib/awx.rb
CHANGED
@@ -29,6 +29,8 @@ module App
|
|
29
29
|
App::AWSProfile::init(Blufin::Config::get)
|
30
30
|
end
|
31
31
|
|
32
|
+
profile = App::AWSProfile::get_profile
|
33
|
+
|
32
34
|
Convoy::App.create do |awx|
|
33
35
|
|
34
36
|
awx.version AWX_VERSION
|
@@ -45,7 +47,7 @@ TEMPLATE
|
|
45
47
|
awx.description 'An abstraction layer built around the AWS-cli (written by: Albert Rannetsperger)'
|
46
48
|
|
47
49
|
# c - CLOUD FORMATION
|
48
|
-
if ARGV[0] != 'setup' && ARGV[0] != 'x' &&
|
50
|
+
if ARGV[0] != 'setup' && ARGV[0] != 'x' && profile.has_key?(App::AWSProfile::CLOUDFORMATION)
|
49
51
|
awx.command :cloudformation, :aliases => [:c] do |awx_cloudformation|
|
50
52
|
awx_cloudformation.summary 'Create, list and delete cloud-formation stacks'
|
51
53
|
# c - CLOUD FORMATION CREATE
|
@@ -93,7 +95,7 @@ TEMPLATE
|
|
93
95
|
end
|
94
96
|
|
95
97
|
# d - DEPLOY (DEPRECATED)
|
96
|
-
if ARGV[0] != 'setup' && ARGV[0] != 'x' && (
|
98
|
+
if ARGV[0] != 'setup' && ARGV[0] != 'x' && (profile.has_key?('Projects'))
|
97
99
|
awx.command :deploy_deprecated, :aliases => [:d] do |deploy_deprecated|
|
98
100
|
deploy_deprecated.summary "Deploy application(s) to AWS #{Blufin::Terminal::format_invalid('@deprecated')}"
|
99
101
|
deploy_deprecated.options do |opts|
|
@@ -106,7 +108,7 @@ TEMPLATE
|
|
106
108
|
end
|
107
109
|
|
108
110
|
# i - INFRASTRUCTURE
|
109
|
-
if ARGV[0] != 'setup' && ARGV[0] != 'x' && (
|
111
|
+
if ARGV[0] != 'setup' && ARGV[0] != 'x' && (profile.has_key?('Projects')) && (profile.has_key?('Deployments'))
|
110
112
|
awx.command :infrastructure, :aliases => [:i] do |infrastructure|
|
111
113
|
infrastructure.summary 'View, modify & deploy application(s) to pre-defined infrastructure'
|
112
114
|
infrastructure.action do |opts, args|
|
@@ -137,12 +139,12 @@ TEMPLATE
|
|
137
139
|
end
|
138
140
|
|
139
141
|
# s - SSH
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
end
|
142
|
+
awx.command :ssh, :aliases => [:s] do |ssh|
|
143
|
+
ssh.summary 'SSH into EC2 instances'
|
144
|
+
ssh.action do |opts, args|
|
145
|
+
AppCommand::SSH.new(opts, args).execute
|
145
146
|
end
|
147
|
+
end
|
146
148
|
|
147
149
|
# S - SWITCH
|
148
150
|
if ARGV[0] != 'setup' && ARGV[0] != 'x' && App::AWSProfile::get_profile_names.length > 1 && !App::AWSProfile::get_credentials.nil?
|
@@ -156,21 +158,34 @@ TEMPLATE
|
|
156
158
|
end
|
157
159
|
|
158
160
|
# u - UPLOAD
|
159
|
-
if ARGV[0] != 'setup' && ARGV[0] != 'x' && (
|
161
|
+
if ARGV[0] != 'setup' && ARGV[0] != 'x' && (
|
162
|
+
(profile.has_key?(App::AWSProfile::DEPLOYMENTS) && profile[App::AWSProfile::DEPLOYMENTS].has_key?('Local')) ||
|
163
|
+
(profile.has_key?(App::AWSProfile::PROJECTS) && profile[App::AWSProfile::PROJECTS].has_key?('Local')) ||
|
164
|
+
(profile.has_key?(App::AWSProfile::CLOUDFORMATION) && profile[App::AWSProfile::CLOUDFORMATION]['Templates'].has_key?('Local')))
|
160
165
|
awx.command :upload, :aliases => [:u] do |upload|
|
161
166
|
upload.summary 'Upload configuration(s) to S3'
|
167
|
+
# d - UPLOAD DEPLOYMENTS
|
168
|
+
if profile.has_key?(App::AWSProfile::DEPLOYMENTS) && profile[App::AWSProfile::DEPLOYMENTS].has_key?('Local')
|
169
|
+
upload.command :deployments, :aliases => [:d] do |upload_deployments|
|
170
|
+
upload_deployments.summary 'Upload Deployments'
|
171
|
+
upload_deployments.action do |opts, args|
|
172
|
+
args = args.unshift(AppCommand::Upload::DEPLOYMENTS)
|
173
|
+
AppCommand::Upload.new(opts, args).execute
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
162
177
|
# p - UPLOAD PROJECTS
|
163
|
-
if App::AWSProfile::
|
178
|
+
if profile.has_key?(App::AWSProfile::PROJECTS) && profile[App::AWSProfile::PROJECTS].has_key?('Local')
|
164
179
|
upload.command :projects, :aliases => [:p] do |upload_projects|
|
165
180
|
upload_projects.summary 'Upload Projects'
|
166
181
|
upload_projects.action do |opts, args|
|
167
|
-
args = args.unshift(
|
182
|
+
args = args.unshift(App::AWSProfile::PROJECTS)
|
168
183
|
AppCommand::Upload.new(opts, args).execute
|
169
184
|
end
|
170
185
|
end
|
171
186
|
end
|
172
|
-
# t - UPLOAD
|
173
|
-
if
|
187
|
+
# t - UPLOAD TEMPLATES
|
188
|
+
if profile.has_key?(App::AWSProfile::CLOUDFORMATION) && profile[App::AWSProfile::CLOUDFORMATION]['Templates'].has_key?('Local')
|
174
189
|
upload.command :templates, :aliases => [:t] do |upload_templates|
|
175
190
|
upload_templates.summary 'Upload Templates'
|
176
191
|
upload_templates.action do |opts, args|
|
@@ -398,7 +398,7 @@ module AppCommand
|
|
398
398
|
category, template, @template = select_template_prompt
|
399
399
|
|
400
400
|
# Will be something like: "ec2/build-server"
|
401
|
-
template_name
|
401
|
+
template_name = "#{category}/#{template}"
|
402
402
|
|
403
403
|
if @params.any?
|
404
404
|
# Here we replace the UUID for the stack-name at the last-second to enable parallel, identical runs (if exists).
|
@@ -570,10 +570,12 @@ module AppCommand
|
|
570
570
|
|
571
571
|
if Blufin::Terminal::prompt_yes_no("Review: #{App::AWSOutputter::render_selection(category, template)}", params_output, 'Create Stack?', false)
|
572
572
|
|
573
|
+
is_ec2 = `#{App::Opt::get_base_path}/#{App::Opt::OPT_PATH}/shell/ec2-check`.to_s.gsub("\n", '') =~ /yes/i
|
574
|
+
|
573
575
|
# If no 'after' actions necessary, give option to terminate script.
|
574
576
|
term_script = false
|
575
|
-
if @template[:method_after_create].nil? && !@template[:single_serve]
|
576
|
-
options = [{:text => "Yes \xe2\x80\x94
|
577
|
+
if @template[:method_after_create].nil? && !@template[:single_serve] && !is_ec2
|
578
|
+
options = [{:text => "Yes \xe2\x80\x94 Wait.", :value => false}, {:text => 'No', :value => true}]
|
577
579
|
help_text = "Select 'No' to end the script immediately. Status can still be viewed in the AWS console."
|
578
580
|
term_script = Blufin::Terminal::prompt_select('Wait for stack to build?', options, help: help_text)
|
579
581
|
puts
|
@@ -596,7 +598,8 @@ module AppCommand
|
|
596
598
|
capabilities: capabilities_arr,
|
597
599
|
term_protect: @template[:single_serve] ? false : @params[OPTION_TERM_PROTECT],
|
598
600
|
term_script: term_script,
|
599
|
-
timeout: @params[OPTION_TIMEOUT]
|
601
|
+
timeout: @params[OPTION_TIMEOUT],
|
602
|
+
open_chrome: !is_ec2)
|
600
603
|
|
601
604
|
# Call :after_create() -- if exists.
|
602
605
|
@template[:method_after_create].call(@params) unless @template[:method_after_create].nil?
|
data/lib/routes/upload.rb
CHANGED
@@ -2,16 +2,18 @@ module AppCommand
|
|
2
2
|
|
3
3
|
class Upload < ::Convoy::ActionCommand::Base
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
DEPLOYMENTS = 'Deployments'
|
6
|
+
PROJECTS = 'Projects'
|
7
|
+
TEMPLATES = 'Templates'
|
7
8
|
|
8
9
|
def execute
|
9
10
|
|
10
11
|
begin
|
11
12
|
|
12
|
-
@opts
|
13
|
-
@args
|
14
|
-
@action
|
13
|
+
@opts = command_options
|
14
|
+
@args = arguments
|
15
|
+
@action = determine_action
|
16
|
+
@profile = App::AWSProfile::get_profile
|
15
17
|
|
16
18
|
opts_validate
|
17
19
|
opts_routing
|
@@ -30,7 +32,48 @@ module AppCommand
|
|
30
32
|
|
31
33
|
def opts_routing
|
32
34
|
|
33
|
-
|
35
|
+
# Get the local path based on upload action.
|
36
|
+
# @profile keys DO NOT need to be validated because we already check them in the awx.rb routing code.
|
37
|
+
case @action
|
38
|
+
when DEPLOYMENTS
|
39
|
+
local_path = @profile[App::AWSProfile::DEPLOYMENTS]['Local']['File']
|
40
|
+
s3_bucket = @profile[App::AWSProfile::DEPLOYMENTS]['S3Bucket']['Name']
|
41
|
+
s3_path = @profile[App::AWSProfile::DEPLOYMENTS]['S3Bucket']['File']
|
42
|
+
s3_region = @profile[App::AWSProfile::DEPLOYMENTS]['S3Bucket']['Region']
|
43
|
+
when PROJECTS
|
44
|
+
local_path = @profile[App::AWSProfile::PROJECTS]['Local']['File']
|
45
|
+
s3_bucket = @profile[App::AWSProfile::PROJECTS]['S3Bucket']['Name']
|
46
|
+
s3_path = @profile[App::AWSProfile::PROJECTS]['S3Bucket']['File']
|
47
|
+
s3_region = @profile[App::AWSProfile::PROJECTS]['S3Bucket']['Region']
|
48
|
+
when TEMPLATES
|
49
|
+
local_path = @profile[App::AWSProfile::CLOUDFORMATION]['Templates']['Local']['Path']
|
50
|
+
s3_bucket = @profile[App::AWSProfile::CLOUDFORMATION]['Templates']['S3Bucket']['Name']
|
51
|
+
s3_path = @profile[App::AWSProfile::CLOUDFORMATION]['Templates']['S3Bucket']['Path']
|
52
|
+
s3_region = @profile[App::AWSProfile::CLOUDFORMATION]['Templates']['S3Bucket']['Region']
|
53
|
+
else
|
54
|
+
raise RuntimeError, "Unrecognized action: #{@action}"
|
55
|
+
end
|
56
|
+
|
57
|
+
# Check that path/file exists.
|
58
|
+
if [TEMPLATES].include?(@action)
|
59
|
+
Blufin::Terminal::error("Path not found: #{Blufin::Terminal::format_directory(local_path)}") unless Blufin::Files::path_exists(local_path)
|
60
|
+
is_file = false
|
61
|
+
else
|
62
|
+
Blufin::Terminal::error("File not found: #{Blufin::Terminal::format_directory(local_path)}") unless Blufin::Files::file_exists(local_path)
|
63
|
+
is_file = true
|
64
|
+
end
|
65
|
+
|
66
|
+
# Do a dryrun first.
|
67
|
+
puts
|
68
|
+
Blufin::AWS::upload_s3_data(s3_bucket, s3_path, local_path, profile: @profile[App::AWSProfile::PROFILE], region: s3_region, is_file: is_file, dryrun: true)
|
69
|
+
puts
|
70
|
+
|
71
|
+
if Blufin::Terminal::prompt_yes?('Sync these files to S3?')
|
72
|
+
# Upload path to S3.
|
73
|
+
s3_path = Blufin::AWS::upload_s3_data(s3_bucket, s3_path, local_path, profile: @profile[App::AWSProfile::PROFILE], region: s3_region, is_file: is_file)
|
74
|
+
# Success Message.
|
75
|
+
Blufin::Terminal::success('Files have been successfully uploaded to S3.', s3_path)
|
76
|
+
end
|
34
77
|
|
35
78
|
end
|
36
79
|
|
@@ -40,7 +83,7 @@ module AppCommand
|
|
40
83
|
# @return void
|
41
84
|
def determine_action
|
42
85
|
action = @args.shift
|
43
|
-
raise RuntimeError, "Invalid action: #{action}. This is an error with your code not your input." unless [PROJECTS, TEMPLATES].include?(action)
|
86
|
+
raise RuntimeError, "Invalid action: #{action}. This is an error with your code not your input." unless [DEPLOYMENTS, PROJECTS, TEMPLATES].include?(action)
|
44
87
|
action
|
45
88
|
end
|
46
89
|
|
data/lib/version.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
AWX_VERSION = '0.6.
|
1
|
+
AWX_VERSION = '0.6.9'
|
data/opt/config/schema.yml
CHANGED
@@ -44,8 +44,8 @@ mapping:
|
|
44
44
|
Region:
|
45
45
|
required: yes
|
46
46
|
Uploads:
|
47
|
-
required: yes
|
48
47
|
type: map
|
48
|
+
required: yes
|
49
49
|
mapping:
|
50
50
|
S3Bucket:
|
51
51
|
type: map
|
@@ -75,6 +75,7 @@ mapping:
|
|
75
75
|
mapping:
|
76
76
|
S3Bucket:
|
77
77
|
type: map
|
78
|
+
required: yes
|
78
79
|
mapping:
|
79
80
|
Name:
|
80
81
|
required: yes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: awx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Albert Rannetsperger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-09-
|
11
|
+
date: 2019-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: blufin-lib
|