capistrano-hivequeen 7.6.0 → 7.7.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
  SHA256:
3
- metadata.gz: 501195df16e5bf37fcbfd70296ba9241a784f7d56670baf7722f6b627ecce049
4
- data.tar.gz: 1c684d9f8f7bd13a28a11d21e987b73f972cadd50f8374599bbcf68a81c6f5e4
3
+ metadata.gz: 72b660b02784362a5c9a2f8a96a3355a3fd18fb399b57d138942488f89b16b10
4
+ data.tar.gz: da9503dc5137e661476abba23820112d59bd4033d0775dbd015e449a0ee889f2
5
5
  SHA512:
6
- metadata.gz: 8e45901e1a5a9968f4b0703a88cabfc7733a9959177321a860c00f35e3492d702b51454a5353c593573e6a35396d6e5a15611bbe7486fe8c597f0acf4523d3ea
7
- data.tar.gz: '09c60243c11e62f0f8bbc5d2d7ae4d95e8795c5fbe0039f4c1d338ba2b0a41caa8f3f5d04d22cbda30d81f69db7c328d8c9bfddfb237ff986f29e075609348b4'
6
+ metadata.gz: 96e6bb88e860b84984b32501ac7be9135364b4ad16a4a644540e8b3cb9f30e655f20f829b5bdcf085e4fc8ba4ddc54d18cc1f36a9a59bef356de48af5f37080a
7
+ data.tar.gz: ca952a870f3db6dafbc36701dcb6708a2902d611fd1abf57783be5607bd3fc0b62523f81ebfd2e7c8f19b45741a549ab7704d79b548c56220185392069bcb6ed
@@ -38,6 +38,8 @@ 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('aws-sdk-ec2', '~> 1.0')
42
+ s.add_dependency('aws-sdk-ec2instanceconnect', '~> 1.0')
41
43
  s.add_dependency('capistrano', '>= 2.11.0')
42
44
  s.add_dependency('activesupport', '>= 3.0.0')
43
45
  s.add_dependency('json')
@@ -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,36 @@
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
+ # EC2 Instance Connect
12
+ ssh_public_key = File.read(File.expand_path('~/.ssh/ksr_ed25519.pub'))
13
+ ec2_params = {
14
+ filters: [{
15
+ name: 'network-interface.private-dns-name',
16
+ values: private_dns
17
+ }]
18
+ }
19
+ logger.trace("ec2:DescribeInstances #{ec2_params.to_json}")
20
+ instances = ec2_client.describe_instances(**ec2_params).reservations.map(&:instances).flatten
21
+ threads = instances.map do |instance|
22
+ Thread.new do
23
+ ec2ic_params = {
24
+ availability_zone: instance.placement.availability_zone,
25
+ instance_id: instance.instance_id,
26
+ instance_os_user: 'ksr',
27
+ ssh_public_key: ssh_public_key,
28
+ }
29
+ logger.trace("ec2-instance-connect:SendSSHPublicKey #{ec2ic_params.to_json}")
30
+ ec2_instance_connect_client.send_ssh_public_key(**ec2ic_params)
31
+ end
32
+ end
33
+
34
+ threads.each(&:join)
35
+ end
36
+ end
@@ -1,6 +1,6 @@
1
1
  class HiveQueen
2
2
  class Version
3
- @@version = '7.6.0'
3
+ @@version = '7.7.0'
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,15 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-hivequeen
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.6.0
4
+ version: 7.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Suggs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-15 00:00:00.000000000 Z
11
+ date: 2022-07-28 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
@@ -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
@@ -116,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
145
  - !ruby/object:Gem::Version
117
146
  version: '0'
118
147
  requirements: []
119
- rubygems_version: 3.0.3
148
+ rubygems_version: 3.3.7
120
149
  signing_key:
121
150
  specification_version: 2
122
151
  summary: Capistrano extensions for interacting with HiveQueen