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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e4d5af31cbe28ce6b554391603524b7b2e1f09c6
4
- data.tar.gz: 0cb46939ed6cd9190d37e8c3ce8ca7687ff7e3dd
3
+ metadata.gz: d5ebb4484b885d8dad52f7413fdaf3c50929d193
4
+ data.tar.gz: 55d319392ca5d5056f071e05831c951f15a59395
5
5
  SHA512:
6
- metadata.gz: e8d0c8cfff6a464bd2393ada3cb073bd885d5114098a47444d7f4a73308f2d3328624af311af8cff3c7a01f30647f5bd66760f125d627f08622d0326d00cf186
7
- data.tar.gz: 6fff147f369b8c82aea3c31b0bac1948eb6d62cdb144288953f2752c010a679d93ff40636ab5ae7be654852c46d852c89acc46be311359e332e60d68c7048f78
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
- # Runs a command on servers with the given role.
7
- #
8
- # @param [String] role_name The value of the 'Role' tag. Can be nil
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 run_remotely(options = {}, &block)
15
- filter_options = options.extract!(:role_name, :environment, :user)
16
- servers = ::Phase.servers.where(filter_options)
17
-
18
- if options.has_key?(:bastion) && bastion = options.delete(:bastion)
19
- hosts = servers.map { |s| {user: options[:user], hostname: s.resource.private_ip_address} }
20
- on_servers_through_bastion(bastion, servers, options, &block)
21
- else
22
- hosts = servers.map { |s| {user: options[:user], hostname: s.resource.dns_name} }
23
- on(hosts, options, &block)
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 on_servers_through_bastion(bastion, servers, options = {}, &block)
28
- ::Phase::Kit::SSH::BastionCoordinator.new(bastion, hosts).run!(options, &block)
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
@@ -1,3 +1,3 @@
1
1
  module Phase
2
- VERSION = "0.0.16"
2
+ VERSION = "0.0.16.1"
3
3
  end
data/lib/phase.rb CHANGED
@@ -4,7 +4,6 @@ require 'colorize'
4
4
  require 'erb'
5
5
  require 'fog'
6
6
  require 'progressbar'
7
- require 'pry'
8
7
  require 'sshkit'
9
8
  require 'terminal-table'
10
9
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phase
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.16
4
+ version: 0.0.16.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piers Mainwaring