qops 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5a359bd27c24df1c4c124864fdc9d409bf43e453
4
- data.tar.gz: 3d42a3143c38fde591eae2969d8abe4d0be36b20
3
+ metadata.gz: becc39290c6daab078f8e2ff60f35580868719e0
4
+ data.tar.gz: 95af5da002ad688a41bd099c9004e5e6b4db3a9a
5
5
  SHA512:
6
- metadata.gz: 4ca05c0d395bbcadfc399ad7a52649f19ebf68520c09acd37bb56c0d86bb9c77cfe0c65dd7639a3c1e6b43c2f9b6f460158a9d94374129806f6832b03b1df78d
7
- data.tar.gz: cfb7726f54f320898ba5c955babb1d1a17bdbcc5695612a740dbb347f743bd49a82fe51264b59184bd638d89484b73423ea7e101372752a821b3deed301eb93c
6
+ metadata.gz: 808fa94972bf2f7f43bbf9d29763230467a93643461d7340e0b131a998f375103256249c7628cad5ecd99296f2bbbe11f49278ee5eacafcf6f6cce7e97d189f4
7
+ data.tar.gz: 76e5233bae516c5e49ce39fcb10db5228004b3fd62cb652a3873ba6c8676ca80ae1f6b97dd0caab6f5af19071998a6ae7ef820d35a39b00aacefa2246b10f89c
@@ -63,12 +63,19 @@ class Qops::Deploy < Thor
63
63
  )
64
64
  )
65
65
 
66
+ tag_instance(first_instance)
67
+
66
68
  # Deploy any remaining instances with migration off for production
67
69
  return unless config.deploy_type == 'production' && online_instances.count > 1
68
70
 
69
71
  print 'Deploying remaining instances ...'
70
72
  deployment_params = base_deployment_params.deep_dup
71
73
  run_opsworks_command(deployment_params)
74
+
75
+ online_instances.each do |instance|
76
+ tag_instance(instance)
77
+ end
78
+
72
79
  ping_slack(
73
80
  'Quandl::Slack::Release',
74
81
  'Deployed All Instances',
@@ -5,6 +5,7 @@ module Qops::DeployHelpers
5
5
 
6
6
  included do
7
7
  class_option :branch, type: :string, aliases: '-b', desc: 'The branch to use when deploying to staging type environments'
8
+ class_option :hostname, type: :string, aliases: '-h', desc: 'Fully override the hostname that qops would normally give the instance'
8
9
  end
9
10
 
10
11
  private
@@ -46,19 +47,41 @@ module Qops::DeployHelpers
46
47
  instances.find { |k| k.hostname == requested_hostname }
47
48
  end
48
49
 
50
+ def tag_instance(instance)
51
+ print "Tagging instance #{instance.hostname}\n"
52
+ config.ec2.create_tags(
53
+ resources: [instance.ec2_instance_id],
54
+ tags: [
55
+ {
56
+ key: 'environment',
57
+ value: config.deploy_type
58
+ }
59
+ ]
60
+ )
61
+ end
62
+
49
63
  def requested_hostname
50
64
  return @requested_hostname if @requested_hostname
51
- if config.deploy_type == 'staging'
52
- @requested_hostname = default_revision.parameterize
53
- elsif config.deploy_type == 'production'
54
- @requested_hostname = config.app_name
55
- existing_hostnames = retrieve_instances.map(&:hostname)
56
- @requested_hostname += "-#{existing_hostnames.sort.last.to_s.split('-').last.to_i + 1}"
65
+ if options[:hostname]
66
+ @requested_hostname = options[:hostname]
67
+ puts "NOTE: You have specified a custom hostname of #{@requested_hostname}. Be sure to continue to use this hostname for future commands to avoid problems."
68
+
69
+ # Alternative flow if user has not overridden the hostname
70
+ else
71
+ if config.deploy_type == 'staging'
72
+ @requested_hostname = default_revision.parameterize
73
+ elsif config.deploy_type == 'production'
74
+ @requested_hostname = config.app_name
75
+ existing_hostnames = retrieve_instances.map(&:hostname)
76
+ @requested_hostname += "-#{existing_hostnames.sort.last.to_s.split('-').last.to_i + 1}"
77
+ end
78
+ @requested_hostname = config.hostname_prefix + @requested_hostname
57
79
  end
58
80
 
59
81
  @requested_hostname = @requested_hostname.gsub(/[^A-Za-z0-9\-]+/, '-').gsub(/-+/, '-')
60
82
  @requested_hostname = @requested_hostname[0..62]
61
83
  @requested_hostname = @requested_hostname.match(/^([A-Za-z0-9\-]+).*$/)[1]
84
+ @requested_hostname
62
85
  end
63
86
 
64
87
  def default_revision
@@ -82,6 +82,7 @@ class Qops::Instance < Thor # rubocop:disable Metrics/ClassLength
82
82
  puts "Public IP: #{instance.public_ip}"
83
83
  puts "Private IP: #{instance.private_ip}"
84
84
 
85
+ tag_instance(instance)
85
86
  setup_instance(instance, initial_instance_state, manifest)
86
87
 
87
88
  if creating_instance
@@ -82,7 +82,11 @@ module Qops
82
82
  end
83
83
 
84
84
  def opsworks
85
- @_opsworks ||= Aws::OpsWorks::Client.new(region: configuration.region)
85
+ @_opsworks_client ||= Aws::OpsWorks::Client.new(region: configuration.region)
86
+ end
87
+
88
+ def ec2
89
+ @_ec2_client ||= Aws::EC2::Client.new(region: configuration.region)
86
90
  end
87
91
 
88
92
  def cookbook_json
@@ -97,6 +101,10 @@ module Qops
97
101
  configuration.root_volume_size || 30
98
102
  end
99
103
 
104
+ def hostname_prefix
105
+ configuration.hostname_prefix || ''
106
+ end
107
+
100
108
  private
101
109
 
102
110
  def method_missing(method_sym, *arguments, &block)
data/lib/qops/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Qops
3
- VERSION = '1.0.0'.freeze
3
+ VERSION = '1.1.0'.freeze
4
4
  end
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.0.0
4
+ version: 1.1.0
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-04 00:00:00.000000000 Z
14
+ date: 2016-04-07 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: thor