def the_host_with_role(role, raise_error=true)
      found_hosts = hosts.select do |h|
        Array(h['roles']).include?(role.to_s)
      end

      if (found_hosts.length == 0 or found_hosts.length > 1) && (raise_error)
        raise ArgumentError, "There should be one host with #{role} defined, found #{found_hosts.length} matching hosts (#{found_hosts})"
      end
      found_hosts.first
    end
def the_host_with_role(role, raise_error=true)
      found_hosts = hosts.select do |h|
        Array(h['roles']).include?(role.to_s)
      end

      if (found_hosts.length == 0 or found_hosts.length > 1) && (raise_error)
        raise ArgumentError, "There should be one host with #{role} defined, found #{found_hosts.length} matching hosts (#{found_hosts})"
      end
      found_hosts.first
    end
Find a single host with the role provided.  Raise an error if more than
 one host is found to have the provided role.

 @param [String] role The host returned will have this role in its role list
 @param [String] raise_error defaults to true if you want this method to return
   an error if there are no hosts, or if there are too many hosts
 @return [Host] The single host with the desired role in its roles list
 @raise [ArgumentError] Raised if more than one host has the given role
   defined, or if no host has the role defined.