phase 0.0.16 → 0.0.16.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/phase/adapters/aws/server.rb +0 -9
- data/lib/phase/dsl.rb +26 -20
- data/lib/phase/version.rb +1 -1
- data/lib/phase.rb +0 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5ebb4484b885d8dad52f7413fdaf3c50929d193
|
4
|
+
data.tar.gz: 55d319392ca5d5056f071e05831c951f15a59395
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6553814d3f824afe7db88505de68b74dfdc07c8468568ec671512552771684bfb764af74856351dcd5cc02051d703da7d1a7be8a8c3812683b941bed5043a49d
|
7
|
+
data.tar.gz: 2e1476f1da9b4f3a8088074c049bb9326ceb4323f2f8b7ece9e4e1bf2de07ec06574047d22a2b4444678eb17eaff0b8e97c604ec2e6c347611a4640250f162f4
|
@@ -3,15 +3,6 @@ module Phase
|
|
3
3
|
module AWS
|
4
4
|
class Server < ::Phase::Adapters::Abstract::Server
|
5
5
|
|
6
|
-
attr_accessor :username
|
7
|
-
|
8
|
-
def to_host_hash(host_method)
|
9
|
-
{
|
10
|
-
user: username,
|
11
|
-
hostname: resource.__send__(host_method)
|
12
|
-
}
|
13
|
-
end
|
14
|
-
|
15
6
|
class << self
|
16
7
|
# @return [Array<AWS::Server>] All known EC2 instances
|
17
8
|
def all
|
data/lib/phase/dsl.rb
CHANGED
@@ -1,31 +1,37 @@
|
|
1
|
-
require 'sshkit/dsl'
|
2
|
-
|
3
1
|
module Phase
|
4
2
|
module DSL
|
5
3
|
|
6
|
-
#
|
7
|
-
#
|
8
|
-
# @param [
|
9
|
-
# @param [String] environment The value of the 'Environment' tag. Can be nil
|
10
|
-
# @param [Hash] options Query and concurrency options
|
11
|
-
# @option options [String] :bastion (true) Whether to connect through a bastion host
|
4
|
+
# @param [String] role_name The value of the 'Role' tag
|
5
|
+
# @param [String] environment The value of the 'Environment' tag
|
6
|
+
# @param [Hash] options SSHKit concurrency options
|
12
7
|
# @see SSHKit::Coordinator for concurrency options
|
13
8
|
# @return [void]
|
14
|
-
def
|
15
|
-
|
16
|
-
servers
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
9
|
+
def on_role(role_name, environment = "staging", options = {}, &block)
|
10
|
+
servers = ::Phase.servers.where(role: role_name, environment: environment)
|
11
|
+
on(servers.map {|s| s.resource.private_ip_address }, options, &block)
|
12
|
+
end
|
13
|
+
|
14
|
+
def on(destination_ips, options = {}, &block)
|
15
|
+
server = ::Phase.servers.where(role: ::Phase.config.bastion_role).first
|
16
|
+
raise ArgumentError, "no servers found" unless server
|
17
|
+
|
18
|
+
# TODO: identify the CORRECT bastion host per subnet/network
|
19
|
+
bastion_host = "#{ ::Phase.config.bastion_user }@#{ server.resource.dns_name }"
|
20
|
+
coordinator = ::SSHKit::Coordinator.new(bastion_host)
|
21
|
+
|
22
|
+
# TODO: clean up this logic. this should be done within a coordinator
|
23
|
+
# (or elsewhere) so we can ID networks on a per-adapter basis
|
24
|
+
results = Array(destination_ips).map do |ip|
|
25
|
+
coordinator.each(options) do
|
26
|
+
on_remote_host(ip) { instance_exec(&block) }
|
27
|
+
end
|
24
28
|
end
|
29
|
+
|
30
|
+
results.flatten
|
25
31
|
end
|
26
32
|
|
27
|
-
def
|
28
|
-
::
|
33
|
+
def run_locally(&block)
|
34
|
+
::SSHKit::Backend::Local.new(&block).run
|
29
35
|
end
|
30
36
|
|
31
37
|
end
|
data/lib/phase/version.rb
CHANGED
data/lib/phase.rb
CHANGED