Method: Beaker::DSL::Patterns#block_on

Defined in:
lib/beaker/dsl/patterns.rb

#block_on(hosts_or_filter, opts = {}, &block) ⇒ Array<Result>, ...

Execute a block selecting the hosts that match with the provided criteria

Parameters:

  • hosts_or_filter (Array<Host>, Host, String, Symbol)

    A host role as a String or Symbol that can be used to search for a set of Hosts, a host name as a String that can be used to search for a set of Hosts, or a Host or Array<Host> to run the block against

  • opts (Hash{Symbol=>String}) (defaults to: {})

    Options to alter execution.

  • block (Block)

    This method will yield to a block of code passed by the caller

Options Hash (opts):

  • :run_in_parallel (Boolean)

    Whether to run on each host in parallel.

Returns:



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/beaker/dsl/patterns.rb', line 26

def block_on hosts_or_filter, opts={}, &block
  block_hosts = nil
  if defined? hosts
    block_hosts = hosts
  end
  filter = nil
  if hosts_or_filter.is_a? String or hosts_or_filter.is_a? Symbol
    filter = hosts_or_filter
  else
    block_hosts = hosts_or_filter
  end
  run_block_on block_hosts, filter, opts, &block
end