qops 1.6.1 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/qops.rb +2 -0
- data/lib/qops/cookbook/cookbook.rb +2 -0
- data/lib/qops/deployment/app.rb +4 -6
- data/lib/qops/deployment/helpers.rb +6 -3
- data/lib/qops/deployment/instances.rb +6 -12
- data/lib/qops/deployment/stacks.rb +2 -0
- data/lib/qops/environment.rb +52 -13
- data/lib/qops/helpers.rb +2 -0
- data/lib/qops/version.rb +1 -1
- metadata +16 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 56a8b43e8bf98e323bbda224d22ca5ad7fcbec726422924acfea24fe31125809
|
4
|
+
data.tar.gz: 5a2c7d2c3929dd29998cf5681decedf5cdec5435ce3b3961a8122cc07425619a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed0c3e2e90a001a916f2e64e8395c35a51a3792dc55093033c494b067133205ad1f83a4d7418c92949539f5fe4ef221c54ad2a85758d9fe351cb538dfa22e256
|
7
|
+
data.tar.gz: 979bac6b722b0f07a45d6a995a00a15a6c17b3c905394f78f5a920bd1b38c2cab6fc531ad06aa3d4c4dc0290c08ec25284d2f980515fe9e7522e24bf2e091ffa
|
data/lib/qops.rb
CHANGED
data/lib/qops/deployment/app.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class Qops::Deploy < Thor
|
2
4
|
include Qops::DeployHelpers
|
3
5
|
|
@@ -8,9 +10,7 @@ class Qops::Deploy < Thor
|
|
8
10
|
instances = config.deploy_type == 'staging' ? [retrieve_instance].compact : retrieve_instances
|
9
11
|
online_instances = instances.select { |instance| instance.status == 'online' }
|
10
12
|
|
11
|
-
if online_instances.empty?
|
12
|
-
raise 'Could not find any running instance(s) to deploy to. Perhaps you need to run "qops:instance:up" first'
|
13
|
-
end
|
13
|
+
raise 'Could not find any running instance(s) to deploy to. Perhaps you need to run "qops:instance:up" first' if online_instances.empty?
|
14
14
|
|
15
15
|
if config.deploy_type == 'staging'
|
16
16
|
puts "Preparing to deploy branch #{revision_used} to instance #{online_instances.first.hostname}"
|
@@ -32,9 +32,7 @@ class Qops::Deploy < Thor
|
|
32
32
|
base_deployment_params[:app_id] = config.application_id
|
33
33
|
end
|
34
34
|
|
35
|
-
if config.deploy_type != 'production'
|
36
|
-
base_deployment_params[:custom_json] = custom_json.to_json
|
37
|
-
end
|
35
|
+
base_deployment_params[:custom_json] = custom_json.to_json if config.deploy_type != 'production'
|
38
36
|
|
39
37
|
manifest = {
|
40
38
|
environment: config.deploy_type
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Qops::DeployHelpers
|
2
4
|
extend ActiveSupport::Concern
|
3
5
|
|
@@ -8,7 +10,8 @@ module Qops::DeployHelpers
|
|
8
10
|
class_option :branch, type: :string, aliases: '-b', desc: 'The branch to use when deploying to staging type environments'
|
9
11
|
class_option :hostname, type: :string, aliases: '-h', desc: 'Fully override the hostname that qops would normally give the instance'
|
10
12
|
class_option :profile, type: :string, aliases: '-p', desc: 'An AWS profile to use'
|
11
|
-
class_option :force_config, type: :boolean, aliases: '-f', desc: '
|
13
|
+
class_option :force_config, type: :boolean, aliases: '-f', desc: 'Force qops to read options from config. by default qops will search aws opsworks stack'
|
14
|
+
class_option :verbose, type: :boolean, aliases: '-v', desc: 'Provides additional information when running for debugging purposes.'
|
12
15
|
end
|
13
16
|
|
14
17
|
private
|
@@ -16,7 +19,7 @@ module Qops::DeployHelpers
|
|
16
19
|
def config
|
17
20
|
return @_config if @_config
|
18
21
|
Qops::Environment.notifiers
|
19
|
-
@_config ||= Qops::Environment.new(profile: options[:profile], force_config: options[:force_config])
|
22
|
+
@_config ||= Qops::Environment.new(profile: options[:profile], force_config: options[:force_config], verbose: options[:verbose])
|
20
23
|
|
21
24
|
fail "Invalid configure deploy_type detected: #{@_config.deploy_type}" unless %w[staging production].include?(@_config.deploy_type)
|
22
25
|
|
@@ -108,7 +111,7 @@ module Qops::DeployHelpers
|
|
108
111
|
return 'master' unless config.deploy_type == 'staging'
|
109
112
|
if options[:branch].present?
|
110
113
|
options[:branch]
|
111
|
-
elsif `git --version` # rubocop:disable Lint/
|
114
|
+
elsif `git --version` # rubocop:disable Lint/LiteralAsCondition
|
112
115
|
`git symbolic-ref --short HEAD`.strip
|
113
116
|
else
|
114
117
|
'master'
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class Qops::Instance < Thor # rubocop:disable Metrics/ClassLength
|
2
4
|
include Qops::DeployHelpers
|
3
5
|
|
@@ -55,9 +57,7 @@ class Qops::Instance < Thor # rubocop:disable Metrics/ClassLength
|
|
55
57
|
|
56
58
|
# Start the instance if necessary
|
57
59
|
print 'Booting instance ...'
|
58
|
-
unless %w[online booting].include?(instance.status)
|
59
|
-
config.opsworks.start_instance(instance_id: instance_id)
|
60
|
-
end
|
60
|
+
config.opsworks.start_instance(instance_id: instance_id) unless %w[online booting].include?(instance.status)
|
61
61
|
|
62
62
|
manifest = {
|
63
63
|
environment: config.deploy_type,
|
@@ -144,9 +144,7 @@ class Qops::Instance < Thor # rubocop:disable Metrics/ClassLength
|
|
144
144
|
def clean
|
145
145
|
initialize_run
|
146
146
|
|
147
|
-
if config.deploy_type == 'production'
|
148
|
-
fail "Cannot clean instances in a #{config.deploy_type} environment"
|
149
|
-
end
|
147
|
+
fail "Cannot clean instances in a #{config.deploy_type} environment" if config.deploy_type == 'production'
|
150
148
|
|
151
149
|
terminated_instances = []
|
152
150
|
|
@@ -297,9 +295,7 @@ class Qops::Instance < Thor # rubocop:disable Metrics/ClassLength
|
|
297
295
|
|
298
296
|
def terminate_instance(instance_id)
|
299
297
|
# Remove schedule if time based instance
|
300
|
-
if config.autoscale_type == 'timer'
|
301
|
-
config.opsworks.set_time_based_auto_scaling(instance_id: instance_id, auto_scaling_schedule: {})
|
302
|
-
end
|
298
|
+
config.opsworks.set_time_based_auto_scaling(instance_id: instance_id, auto_scaling_schedule: {}) if config.autoscale_type == 'timer'
|
303
299
|
|
304
300
|
# Get the instance from the id
|
305
301
|
instance = retrieve_instance(instance_id)
|
@@ -314,9 +310,7 @@ class Qops::Instance < Thor # rubocop:disable Metrics/ClassLength
|
|
314
310
|
|
315
311
|
# Attempt to shutdown the instance
|
316
312
|
print "Attempting instance #{instance_id} - #{instance.hostname} shutdown ..."
|
317
|
-
unless instance.status == 'stopped'
|
318
|
-
config.opsworks.stop_instance(instance_id: instance_id)
|
319
|
-
end
|
313
|
+
config.opsworks.stop_instance(instance_id: instance_id) unless instance.status == 'stopped'
|
320
314
|
|
321
315
|
manifest = {
|
322
316
|
environment: config.deploy_type,
|
data/lib/qops/environment.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'quandl/config'
|
2
4
|
|
3
5
|
module Qops
|
@@ -26,17 +28,36 @@ module Qops
|
|
26
28
|
puts Rainbow(message).bg(:black).red
|
27
29
|
when :warning
|
28
30
|
puts Rainbow(message).bg(:black).yellow
|
31
|
+
when :good
|
32
|
+
puts Rainbow(message).bg(:black).green
|
29
33
|
else
|
30
34
|
puts message
|
31
35
|
end
|
32
36
|
end
|
33
37
|
|
34
|
-
def initialize(profile: nil, force_config: false)
|
38
|
+
def initialize(profile: nil, force_config: false, verbose: false)
|
35
39
|
@_aws_config = { region: configuration.region }
|
36
40
|
@_aws_config[:profile] = profile unless profile.nil?
|
41
|
+
|
37
42
|
@_force_config = force_config
|
38
|
-
|
39
|
-
|
43
|
+
@_verbose = verbose
|
44
|
+
|
45
|
+
if profile.nil?
|
46
|
+
opsworks.config.credentials.credentials
|
47
|
+
else
|
48
|
+
parsed_creds = Aws.shared_config.instance_variable_get('@parsed_credentials')[profile]
|
49
|
+
role_credentials = Aws::AssumeRoleCredentials.new(
|
50
|
+
role_arn: parsed_creds['role_arn'],
|
51
|
+
role_session_name: profile
|
52
|
+
)
|
53
|
+
# Aws::OpsWorks::Client.new(credentials: role_credentials).describe_stacks.stacks.each { |s| puts s }
|
54
|
+
@_aws_config[:credentials] = role_credentials
|
55
|
+
|
56
|
+
puts Rainbow("Using AWS profile #{profile}").bg(:black).green
|
57
|
+
end
|
58
|
+
|
59
|
+
Aws.config.update(@_aws_config)
|
60
|
+
|
40
61
|
puts Rainbow('Forcing Qops to read the opsworks parameter strictly from yaml') if force_config
|
41
62
|
%w[deploy_type region app_name].each do |v|
|
42
63
|
fail "Please configure #{v} before continuing." unless option?(v)
|
@@ -55,12 +76,12 @@ module Qops
|
|
55
76
|
end
|
56
77
|
|
57
78
|
def stack_id(options = {})
|
58
|
-
return configuration.stack_id if
|
79
|
+
return configuration.stack_id if force_config?
|
59
80
|
stack(options).stack_id
|
60
81
|
end
|
61
82
|
|
62
83
|
def subnet(options = {})
|
63
|
-
return configuration.subnet if
|
84
|
+
return configuration.subnet if force_config?
|
64
85
|
stack(options).default_subnet_id
|
65
86
|
end
|
66
87
|
|
@@ -69,9 +90,9 @@ module Qops
|
|
69
90
|
end
|
70
91
|
|
71
92
|
def layer_id(_options = {})
|
72
|
-
return configuration.layer_id if
|
93
|
+
return configuration.layer_id if force_config?
|
73
94
|
name = configuration.layer_name
|
74
|
-
|
95
|
+
verbose_output("Searching for layer : #{name}")
|
75
96
|
layer = layers.find { |l| l.name.match(/#{name}/i) }
|
76
97
|
layer.layer_id
|
77
98
|
end
|
@@ -85,7 +106,7 @@ module Qops
|
|
85
106
|
end
|
86
107
|
|
87
108
|
def application_id(options = {})
|
88
|
-
return configuration.application_id if
|
109
|
+
return configuration.application_id if force_config?
|
89
110
|
apps(options).first.app_id
|
90
111
|
end
|
91
112
|
|
@@ -136,13 +157,25 @@ module Qops
|
|
136
157
|
end
|
137
158
|
|
138
159
|
def elb
|
139
|
-
@_elb_client ||= Aws::ElasticLoadBalancing::Client.new(
|
160
|
+
@_elb_client ||= Aws::ElasticLoadBalancing::Client.new(**@_aws_config)
|
140
161
|
end
|
141
162
|
|
142
163
|
def cookbook_json
|
143
164
|
configuration.cookbook_json || 'custom.json'
|
144
165
|
end
|
145
166
|
|
167
|
+
def verbose?
|
168
|
+
@_verbose
|
169
|
+
end
|
170
|
+
|
171
|
+
def verbose_output(text)
|
172
|
+
self.class.print_with_colour(text, :warning) if verbose?
|
173
|
+
end
|
174
|
+
|
175
|
+
def force_config?
|
176
|
+
@_force_config
|
177
|
+
end
|
178
|
+
|
146
179
|
def option?(key)
|
147
180
|
respond_to?(key.to_sym) || configuration.instance_variable_get(:@table).keys.include?(key.to_sym)
|
148
181
|
end
|
@@ -172,18 +205,24 @@ module Qops
|
|
172
205
|
:stack_id
|
173
206
|
else
|
174
207
|
id = identity_from_config
|
175
|
-
|
176
|
-
puts(msg.bg(:black).green)
|
208
|
+
self.class.print_with_colour("Using opsworks.yml config #{id}: #{configuration.send(id)}", :good)
|
177
209
|
id
|
178
210
|
end
|
179
211
|
end
|
180
212
|
|
181
213
|
def search_stack(key, value)
|
182
|
-
stack
|
214
|
+
verbose_output("Searching for stack : #{value}")
|
215
|
+
|
216
|
+
stack = opsworks.describe_stacks.stacks.find do |s|
|
217
|
+
verbose_output("Found stack: #{s.send(key)}")
|
218
|
+
s.send(key) == value
|
219
|
+
end
|
220
|
+
|
183
221
|
unless stack
|
184
|
-
|
222
|
+
self.class.print_with_colour("Could not find stack with #{key} = #{value}", :error)
|
185
223
|
exit(-1)
|
186
224
|
end
|
225
|
+
|
187
226
|
stack
|
188
227
|
end
|
189
228
|
|
data/lib/qops/helpers.rb
CHANGED
data/lib/qops/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qops
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Basset
|
@@ -12,22 +12,22 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date:
|
15
|
+
date: 2018-01-25 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
|
-
name:
|
18
|
+
name: activesupport
|
19
19
|
requirement: !ruby/object:Gem::Requirement
|
20
20
|
requirements:
|
21
21
|
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version:
|
23
|
+
version: 4.2.1
|
24
24
|
type: :runtime
|
25
25
|
prerelease: false
|
26
26
|
version_requirements: !ruby/object:Gem::Requirement
|
27
27
|
requirements:
|
28
28
|
- - ">="
|
29
29
|
- !ruby/object:Gem::Version
|
30
|
-
version:
|
30
|
+
version: 4.2.1
|
31
31
|
- !ruby/object:Gem::Dependency
|
32
32
|
name: aws-sdk
|
33
33
|
requirement: !ruby/object:Gem::Requirement
|
@@ -71,33 +71,33 @@ dependencies:
|
|
71
71
|
- !ruby/object:Gem::Version
|
72
72
|
version: '0'
|
73
73
|
- !ruby/object:Gem::Dependency
|
74
|
-
name:
|
74
|
+
name: rainbow
|
75
75
|
requirement: !ruby/object:Gem::Requirement
|
76
76
|
requirements:
|
77
|
-
- - "
|
77
|
+
- - "~>"
|
78
78
|
- !ruby/object:Gem::Version
|
79
|
-
version:
|
79
|
+
version: 2.0.0
|
80
80
|
type: :runtime
|
81
81
|
prerelease: false
|
82
82
|
version_requirements: !ruby/object:Gem::Requirement
|
83
83
|
requirements:
|
84
|
-
- - "
|
84
|
+
- - "~>"
|
85
85
|
- !ruby/object:Gem::Version
|
86
|
-
version:
|
86
|
+
version: 2.0.0
|
87
87
|
- !ruby/object:Gem::Dependency
|
88
|
-
name:
|
88
|
+
name: thor
|
89
89
|
requirement: !ruby/object:Gem::Requirement
|
90
90
|
requirements:
|
91
|
-
- - "
|
91
|
+
- - ">="
|
92
92
|
- !ruby/object:Gem::Version
|
93
|
-
version:
|
93
|
+
version: 0.20.0
|
94
94
|
type: :runtime
|
95
95
|
prerelease: false
|
96
96
|
version_requirements: !ruby/object:Gem::Requirement
|
97
97
|
requirements:
|
98
|
-
- - "
|
98
|
+
- - ">="
|
99
99
|
- !ruby/object:Gem::Version
|
100
|
-
version:
|
100
|
+
version: 0.20.0
|
101
101
|
description: Help to automate opsworks project deployments with single commands.
|
102
102
|
email:
|
103
103
|
- support@quandl.com
|
@@ -137,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
137
|
version: '0'
|
138
138
|
requirements: []
|
139
139
|
rubyforge_project:
|
140
|
-
rubygems_version: 2.
|
140
|
+
rubygems_version: 2.7.4
|
141
141
|
signing_key:
|
142
142
|
specification_version: 4
|
143
143
|
summary: Helper commands for deployment of opsworks projects.
|