Method: Beaker::Shared::HostManager#hosts_with_role

Defined in:
lib/beaker/shared/host_manager.rb

#hosts_with_role(hosts, desired_role = nil) ⇒ Array<Host>

Find hosts from a given array of hosts that all have the desired role.

Parameters:

  • hosts (Array<Host>)

    The hosts to examine

  • desired_role (String) (defaults to: nil)

    The hosts returned will have this role in their roles list

Returns:

  • (Array<Host>)

    The hosts that have the desired role in their roles list



14
15
16
17
18
# File 'lib/beaker/shared/host_manager.rb', line 14

def hosts_with_role(hosts, desired_role = nil)
  hosts.select do |host|
    desired_role.nil? or host['roles'].include?(desired_role.to_s)
  end
end