capistrano-hivequeen 7.5.0 → 7.7.1

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
  SHA256:
3
- metadata.gz: 9b66d4218316f1fa5e21db271700c8c3f1b6e69312912eb106d04cecef5aa704
4
- data.tar.gz: c2d33bdb0f6f09d376f0e5cb49f3c230507b4562fac6ce75def53f5aeb7ebe3a
3
+ metadata.gz: 8ca77135ec2da064aa528ee926c64e0ff2cf97615aed3a8aa1d72813b3a8fb70
4
+ data.tar.gz: b456eb78e4f914da4fc6a5eaa3a99f0902336c2951b26437d4bf403f44f7bcae
5
5
  SHA512:
6
- metadata.gz: daf7410d13f08728bdc618bc95f79e7bf40e75af00658379e48e063970c8151ba94e0b4a16dc525e6f89bac31e991ba6858b1652a72c6d83eef1c654db00e261
7
- data.tar.gz: cb2806cab76537e07daa39d6cdf6d3ec40d991c3eca37f6e806615fb8d4ac51d8f76744d81ea48628247899471c4e20fe4d0dd89ed492aee1a1cdaf1a2258cfd
6
+ metadata.gz: 1efcaa3895d677e108d881d3843b3d7a83343218e0d5d3868db439c85d33f0bf038d6ea0f2a31d0e22e5fcd707b23a99c1016d502b0244715ec785c923d6a64f
7
+ data.tar.gz: 97a8ea9475a996d9bb820c0c99bd55fbf7af635b30803e1f7a92ad3c64902bba5153560f49d9fa64486ecf0b6495985b31ae050ed14d19655bcc5c3105219d91
data/.gitignore CHANGED
@@ -1 +1,2 @@
1
1
  *.gem
2
+ .ruby-version
data/README.rdoc CHANGED
@@ -27,6 +27,12 @@ And in your config/deploy.rb:
27
27
 
28
28
  cap staging deploy -s branch=some_feature
29
29
 
30
+ === Releasing a new version
31
+ First, bump the version in lib/capistrano/hivequeen/version.rb. Then:
32
+
33
+ gem build capistrano-hivequeen.gemspec
34
+ gem push capistrano-hivequeen-$VERSION.gem
35
+
30
36
  == License
31
37
 
32
38
  @copy; Copyright Kickstarter, PBC.
@@ -38,7 +38,9 @@ Gem::Specification.new do |s|
38
38
 
39
39
  ## List your runtime dependencies here. Runtime dependencies are those
40
40
  ## that are needed for an end user to actually USE your code.
41
- s.add_dependency('capistrano', '>= 2.11.0')
41
+ s.add_dependency('aws-sdk-ec2', '~> 1.0')
42
+ s.add_dependency('aws-sdk-ec2instanceconnect', '~> 1.0')
43
+ s.add_dependency('capistrano', '~> 2.11')
42
44
  s.add_dependency('activesupport', '>= 3.0.0')
43
45
  s.add_dependency('json')
44
46
  s.add_dependency('egads', '>= 3.0.0')
@@ -78,7 +78,7 @@ Capistrano::Configuration.instance(:must_exist).load do
78
78
  if exists?(:az)
79
79
  servers = servers.select {|s| s['availability_zone'] == az}
80
80
  end
81
- role(role_name.to_sym) { servers.map {|s| s['public_dns']} }
81
+ role(role_name.to_sym) { servers.map {|s| s['public_dns'] || s['private_dns']} }
82
82
  end
83
83
 
84
84
  # Ensure some server designated as db server
@@ -97,14 +97,18 @@ Capistrano::Configuration.instance(:must_exist).load do
97
97
  command_format = "ssh -t -A -l %s %s"
98
98
  env['roles'].keys.each do |role_name|
99
99
  task role_name do
100
- cmd = command_format % [user, roles[role_name.to_sym].servers.first]
100
+ server = roles[role_name.to_sym].servers.sample
101
+ HiveQueen.ec2_instance_connect(server.host)
102
+ cmd = command_format % [user, server]
101
103
  puts "Executing #{cmd}"
102
104
  exec cmd
103
105
  end
104
106
  end
105
107
 
106
108
  task :default do
107
- cmd = command_format % [user, roles.values.sample.servers.sample]
109
+ server = roles.values.sample.servers.sample
110
+ HiveQueen.ec2_instance_connect(server.host)
111
+ cmd = command_format % [user, server]
108
112
  puts "Executing #{cmd}"
109
113
  exec cmd
110
114
  end
@@ -114,14 +118,18 @@ Capistrano::Configuration.instance(:must_exist).load do
114
118
  command_format = "ssh -t -A -l %s %s 'source /etc/profile; cd /apps/#{HiveQueen.project}/current && bundle exec rails console'"
115
119
  env['roles'].keys.each do |role_name|
116
120
  task role_name do
121
+ server = roles[role_name.to_sym].servers.sample
122
+ HiveQueen.ec2_instance_connect(server.host)
117
123
  puts "Opening console"
118
- exec command_format % [user, roles[role_name.to_sym].servers.first]
124
+ exec command_format % [user, server]
119
125
  end
120
126
  end
121
127
 
122
128
  task :default do
129
+ server = roles.values.sample.servers.sample
130
+ HiveQueen.ec2_instance_connect(server.host)
123
131
  puts "Opening console"
124
- exec command_format % [user, roles.values.sample.servers.sample]
132
+ exec command_format % [user, server]
125
133
  end
126
134
  end
127
135
  end
@@ -0,0 +1,41 @@
1
+ class HiveQueen
2
+ def self.ec2_client
3
+ @ec2_client ||= Aws::EC2::Client.new
4
+ end
5
+
6
+ def self.ec2_instance_connect_client
7
+ @ec2_instance_connect_client ||= Aws::EC2InstanceConnect::Client.new
8
+ end
9
+
10
+ def self.ec2_instance_connect(*private_dns)
11
+ # Get SSH public key contents
12
+ ssh_public_key = File.read(File.expand_path('~/.ssh/ksr_ed25519.pub'))
13
+
14
+ # Get SSH bastion instance(s) from Name tag
15
+ ssh_params = { filters: [{ name: 'tag:Name', values: %w[ssh-bastion] }] }
16
+ logger.trace("ec2:DescribeInstances #{ssh_params.to_json}")
17
+ bastions = ec2_client.describe_instances(**ssh_params).reservations.map(&:instances).flatten
18
+
19
+ # Get EC2 instances from private DNS name
20
+ ec2_params = { filters: [{ name: 'network-interface.private-dns-name', values: private_dns }] }
21
+ logger.trace("ec2:DescribeInstances #{ec2_params.to_json}")
22
+ instances = ec2_client.describe_instances(**ec2_params).reservations.map(&:instances).flatten
23
+
24
+ # Collect EC2 Instance Connect request threads
25
+ threads = (bastions + instances).map do |instance|
26
+ Thread.new do
27
+ ec2ic_params = {
28
+ availability_zone: instance.placement.availability_zone,
29
+ instance_id: instance.instance_id,
30
+ instance_os_user: 'ksr',
31
+ ssh_public_key: ssh_public_key,
32
+ }
33
+ logger.trace("ec2-instance-connect:SendSSHPublicKey #{ec2ic_params.to_json}")
34
+ ec2_instance_connect_client.send_ssh_public_key(**ec2ic_params)
35
+ end
36
+ end
37
+
38
+ # Execute EC2 Instance Connect request threads
39
+ threads.each(&:join)
40
+ end
41
+ end
@@ -1,6 +1,6 @@
1
1
  class HiveQueen
2
2
  class Version
3
- @@version = '7.5.0'
3
+ @@version = '7.7.1'
4
4
 
5
5
  def self.to_s
6
6
  @@version
@@ -1,12 +1,17 @@
1
1
  # HTTP Client for Hive Queen environment configuration
2
+ require 'base64'
3
+ require 'fileutils'
2
4
  require 'json'
5
+
3
6
  require 'active_support'
4
7
  require 'active_support/core_ext'
5
- require 'fileutils'
8
+ require 'aws-sdk-ec2'
9
+ require 'aws-sdk-ec2instanceconnect'
6
10
  require 'excon'
7
- require 'base64'
11
+
8
12
  require 'capistrano/hivequeen/version'
9
13
  require 'capistrano/hivequeen/multiio'
14
+ require 'capistrano/hivequeen/ec2_instance_connect'
10
15
 
11
16
  # Special cases:
12
17
  # - environment not found
@@ -135,4 +140,3 @@ class HiveQueen
135
140
  end
136
141
 
137
142
  require "capistrano/hivequeen/capistrano_configuration"
138
-
metadata CHANGED
@@ -1,29 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-hivequeen
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.5.0
4
+ version: 7.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Suggs
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-06 00:00:00.000000000 Z
11
+ date: 2022-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: aws-sdk-ec2
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: aws-sdk-ec2instanceconnect
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
13
41
  - !ruby/object:Gem::Dependency
14
42
  name: capistrano
15
43
  requirement: !ruby/object:Gem::Requirement
16
44
  requirements:
17
- - - ">="
45
+ - - "~>"
18
46
  - !ruby/object:Gem::Version
19
- version: 2.11.0
47
+ version: '2.11'
20
48
  type: :runtime
21
49
  prerelease: false
22
50
  version_requirements: !ruby/object:Gem::Requirement
23
51
  requirements:
24
- - - ">="
52
+ - - "~>"
25
53
  - !ruby/object:Gem::Version
26
- version: 2.11.0
54
+ version: '2.11'
27
55
  - !ruby/object:Gem::Dependency
28
56
  name: activesupport
29
57
  requirement: !ruby/object:Gem::Requirement
@@ -93,6 +121,7 @@ files:
93
121
  - lib/capistrano/hivequeen.rb
94
122
  - lib/capistrano/hivequeen/capistrano_configuration.rb
95
123
  - lib/capistrano/hivequeen/deploy.rb
124
+ - lib/capistrano/hivequeen/ec2_instance_connect.rb
96
125
  - lib/capistrano/hivequeen/multiio.rb
97
126
  - lib/capistrano/hivequeen/setup.rb
98
127
  - lib/capistrano/hivequeen/version.rb
@@ -100,7 +129,7 @@ homepage: http://github.com/kickstarter/capistrano-hivequeen
100
129
  licenses:
101
130
  - MIT
102
131
  metadata: {}
103
- post_install_message:
132
+ post_install_message:
104
133
  rdoc_options:
105
134
  - "--charset=UTF-8"
106
135
  require_paths:
@@ -116,9 +145,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
145
  - !ruby/object:Gem::Version
117
146
  version: '0'
118
147
  requirements: []
119
- rubyforge_project:
120
- rubygems_version: 2.7.6
121
- signing_key:
148
+ rubygems_version: 3.1.6
149
+ signing_key:
122
150
  specification_version: 2
123
151
  summary: Capistrano extensions for interacting with HiveQueen
124
152
  test_files: []