def minions_filtered(role_filter = 'all')
      # # puts (stage_roles.values.each_with_object({}) { |node, nodes| nodes.merge!(node) }).inspect
      # # stage_roles.values.each_with_object({}) { |node, nodes| nodes.merge!(node) }
      # nodes = stage_roles.each_with_object({}) do |(role, node), nodes|
      #   if role_filter == 'all' || role == role_filter
      #     nodes.merge!(node)
      #   end
      # end
      # # puts nodes.inspect
      # # puts "nodes_in_stage: only first returned"+"!*"*80
      # # out = {}
      # # out["memcached"] = nodes["memcached"]
      # # puts out.inspect
      # # out
      if role_filter == 'all'
        minions
      else
        minions.select { |minion_name, minion| minion.has_role?(role_filter) }
      end

    end
def minions_filtered(role_filter = 'all')
      # # puts (stage_roles.values.each_with_object({}) { |node, nodes| nodes.merge!(node) }).inspect
      # # stage_roles.values.each_with_object({}) { |node, nodes| nodes.merge!(node) }
      # nodes = stage_roles.each_with_object({}) do |(role, node), nodes|
      #   if role_filter == 'all' || role == role_filter
      #     nodes.merge!(node)
      #   end
      # end
      # # puts nodes.inspect
      # # puts "nodes_in_stage: only first returned"+"!*"*80
      # # out = {}
      # # out["memcached"] = nodes["memcached"]
      # # puts out.inspect
      # # out
      if role_filter == 'all'
        minions
      else
        minions.select { |minion_name, minion| minion.has_role?(role_filter) }
      end

    end
# find node by full node_name or by matching prefix of node_name
 def find_node(node_name, raise_error = true)
   # raise(Thor::Error, "Node not specified.") if node_name.nil? || node_name.empty?
   raise('Node not specified.') if node_name.nil? || node_name.empty?
   return {node_name => nodes_in_stage[node_name]} if nodes_in_stage[node_name]
   nodes_in_stage.each do |key, value|
     return {key => value} if key.start_with?(node_name)
   end
   raise("Not found:  #{node_name} in #{stage_name}.") if raise_error
   # raise(Thor::Error, "Not found:  #{node_name} in #{stage_name}.")
 end