Module: Phase::DSL

Defined in:
lib/phase/dsl.rb

Instance Method Summary collapse

Instance Method Details

#on_servers_through_bastion(bastion, servers, options = {}, &block) ⇒ Object



27
28
29
# File 'lib/phase/dsl.rb', line 27

def on_servers_through_bastion(bastion, servers, options = {}, &block)
  ::Phase::Kit::SSH::BastionCoordinator.new(bastion, hosts).run!(options, &block)
end

#run_remotely(options = {}, &block) ⇒ void

This method returns an undefined value.

Runs a command on servers with the given role.

Parameters:

  • role_name (String)

    The value of the ‘Role’ tag. Can be nil

  • environment (String)

    The value of the ‘Environment’ tag. Can be nil

  • options (Hash) (defaults to: {})

    Query and concurrency options

Options Hash (options):

  • :bastion (String) — default: true

    Whether to connect through a bastion host

See Also:

  • for concurrency options


14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/phase/dsl.rb', line 14

def run_remotely(options = {}, &block)
  filter_options = options.extract!(:role_name, :environment, :user)
  servers = ::Phase.servers.where(filter_options)

  if options.has_key?(:bastion) && bastion = options.delete(:bastion)
    hosts = servers.map { |s| {user: options[:user], hostname: s.resource.private_ip_address} }
    on_servers_through_bastion(bastion, servers, options, &block)
  else
    hosts = servers.map { |s| {user: options[:user], hostname: s.resource.dns_name} }
    on(hosts, options, &block)
  end
end