qops 1.2.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/qops/deployment/app.rb +2 -4
- data/lib/qops/deployment/helpers.rb +27 -8
- data/lib/qops/deployment/instances.rb +13 -0
- data/lib/qops/version.rb +1 -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: 5ce6ec6898479b478e84f3f9b124daaa7f0b55fc
|
4
|
+
data.tar.gz: 5864daf206d6cb82473cd1cc74ce2a885b499108
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d753d119a25815cc5814b55fb678602e5d16853b8ae399b3b47a04d6251e097ec1eb56520741980b7a7cec72f38d90d896b5e4769a6721bbe644cc67fb768783
|
7
|
+
data.tar.gz: 5ff39709b94f8142fa0e80d6c3497a8fed9f5d9360777f3eb32692de575b2ad32c027b86031c806d5b064eb4ae57709f8f7435d967599ec1f42d5b5927205126
|
data/lib/qops/deployment/app.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
class Qops::Deploy < Thor
|
2
2
|
include Qops::DeployHelpers
|
3
3
|
|
4
|
-
class_option :custom_json, type: :string, aliases: '-j', desc: 'A custom json that will be used during a deployment of the app. ex: \'{ "custom_attrs": "are awesome!"}\''
|
5
|
-
|
6
4
|
desc 'app', 'Deploy the latest version of the app'
|
7
5
|
def app
|
8
6
|
initialize_run
|
@@ -19,7 +17,7 @@ class Qops::Deploy < Thor
|
|
19
17
|
end
|
20
18
|
|
21
19
|
if config.deploy_type == 'staging'
|
22
|
-
puts "Preparing to deploy branch #{
|
20
|
+
puts "Preparing to deploy branch #{revision_used} to instance #{online_instances.first.hostname}"
|
23
21
|
else
|
24
22
|
puts "Preparing to deploy default branch to all (online) servers (#{online_instances.map(&:hostname).join(', ')})"
|
25
23
|
end
|
@@ -104,7 +102,7 @@ class Qops::Deploy < Thor
|
|
104
102
|
@_custom_json[:deploy] = {
|
105
103
|
application_name => {
|
106
104
|
scm: {
|
107
|
-
revision:
|
105
|
+
revision: revision_used
|
108
106
|
}
|
109
107
|
}
|
110
108
|
}
|
@@ -4,6 +4,7 @@ module Qops::DeployHelpers
|
|
4
4
|
include Qops::Helpers
|
5
5
|
|
6
6
|
included do
|
7
|
+
class_option :custom_json, type: :string, aliases: '-j', desc: 'A custom json that will be used during a deployment of the app. ex: \'{ "custom_attrs": "are awesome!"}\''
|
7
8
|
class_option :branch, type: :string, aliases: '-b', desc: 'The branch to use when deploying to staging type environments'
|
8
9
|
class_option :hostname, type: :string, aliases: '-h', desc: 'Fully override the hostname that qops would normally give the instance'
|
9
10
|
end
|
@@ -49,14 +50,32 @@ module Qops::DeployHelpers
|
|
49
50
|
|
50
51
|
def tag_instance(instance)
|
51
52
|
print "Tagging instance #{instance.hostname}\n"
|
53
|
+
|
54
|
+
tags = [
|
55
|
+
{
|
56
|
+
key: 'environment',
|
57
|
+
value: config.deploy_type
|
58
|
+
},
|
59
|
+
{
|
60
|
+
key: 'branch',
|
61
|
+
value: revision_used
|
62
|
+
},
|
63
|
+
{
|
64
|
+
key: 'app',
|
65
|
+
value: config.app_name
|
66
|
+
}
|
67
|
+
]
|
68
|
+
|
69
|
+
if config.deploy_type == 'staging'
|
70
|
+
tags << {
|
71
|
+
key: 'cleanable',
|
72
|
+
value: 'true'
|
73
|
+
}
|
74
|
+
end
|
75
|
+
|
52
76
|
config.ec2.create_tags(
|
53
77
|
resources: [instance.ec2_instance_id],
|
54
|
-
tags:
|
55
|
-
{
|
56
|
-
key: 'environment',
|
57
|
-
value: config.deploy_type
|
58
|
-
}
|
59
|
-
]
|
78
|
+
tags: tags
|
60
79
|
)
|
61
80
|
end
|
62
81
|
|
@@ -69,7 +88,7 @@ module Qops::DeployHelpers
|
|
69
88
|
# Alternative flow if user has not overridden the hostname
|
70
89
|
else
|
71
90
|
if config.deploy_type == 'staging'
|
72
|
-
@requested_hostname =
|
91
|
+
@requested_hostname = revision_used.parameterize
|
73
92
|
elsif config.deploy_type == 'production'
|
74
93
|
@requested_hostname = config.app_name
|
75
94
|
existing_hostnames = retrieve_instances.map(&:hostname)
|
@@ -84,7 +103,7 @@ module Qops::DeployHelpers
|
|
84
103
|
@requested_hostname
|
85
104
|
end
|
86
105
|
|
87
|
-
def
|
106
|
+
def revision_used
|
88
107
|
return 'master' unless config.deploy_type == 'staging'
|
89
108
|
if options[:branch].present?
|
90
109
|
options[:branch]
|
@@ -154,6 +154,19 @@ class Qops::Instance < Thor # rubocop:disable Metrics/ClassLength
|
|
154
154
|
retrieve_instances.each do |instance|
|
155
155
|
next if instance.hostname == "#{config.hostname_prefix}master"
|
156
156
|
|
157
|
+
ec2instances = config.ec2.describe_instances(instance_ids: [instance.ec2_instance_id])
|
158
|
+
next if ec2instances.reservations.empty?
|
159
|
+
|
160
|
+
# Get various tag values
|
161
|
+
ec2instance = ec2instances.reservations.first.instances.first
|
162
|
+
environment = ec2instance.tags.find { |t| t.key == 'environment' }
|
163
|
+
cleanable = ec2instance.tags.find { |t| t.key == 'cleanable' }
|
164
|
+
branch = ec2instance.tags.find { |t| t.key == 'branch' }
|
165
|
+
|
166
|
+
next if !cleanable || cleanable.value != 'true'
|
167
|
+
next if !environment || environment.value != 'staging'
|
168
|
+
next if !branch || branch.value == 'master'
|
169
|
+
|
157
170
|
# Find the latest command since the instance was deployed
|
158
171
|
latest_command = Time.parse(instance.created_at)
|
159
172
|
config.opsworks.describe_commands(instance_id: instance.instance_id).commands.each do |command|
|
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.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Basset
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2016-04-
|
14
|
+
date: 2016-04-25 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: qthor
|