Module: Phase::DSL
- Defined in:
- lib/phase/dsl.rb
Instance Method Summary collapse
- #on(destination_ips, options = {}, &block) ⇒ Object
- #on_role(role_name, environment = "staging", options = {}, &block) ⇒ void
- #run_locally(&block) ⇒ Object
Instance Method Details
#on(destination_ips, options = {}, &block) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/phase/dsl.rb', line 14 def on(destination_ips, = {}, &block) server = ::Phase.servers.where(role: ::Phase.config.bastion_role).first raise ArgumentError, "no servers found" unless server # TODO: identify the CORRECT bastion host per subnet/network bastion_host = "#{ ::Phase.config.bastion_user }@#{ server.resource.dns_name }" coordinator = ::SSHKit::Coordinator.new(bastion_host) # TODO: clean up this logic. this should be done within a coordinator # (or elsewhere) so we can ID networks on a per-adapter basis results = Array(destination_ips).map do |ip| coordinator.each() do on_remote_host(ip) { instance_exec(&block) } end end results.flatten end |
#on_role(role_name, environment = "staging", options = {}, &block) ⇒ void
This method returns an undefined value.
9 10 11 12 |
# File 'lib/phase/dsl.rb', line 9 def on_role(role_name, environment = "staging", = {}, &block) servers = ::Phase.servers.where(role: role_name, environment: environment) on(servers.map {|s| s.resource.private_ip_address }, , &block) end |
#run_locally(&block) ⇒ Object
33 34 35 |
# File 'lib/phase/dsl.rb', line 33 def run_locally(&block) ::SSHKit::Backend::Local.new(&block).run end |