module Puppet::Parser::Functions
  newfunction(:nodes_with_roles, :type => :rvalue, :doc => <<-EOS
Return a list of nodes that have one of the given roles. If attr is defined,
return just that attribute for each node instead of the whole node hash.
EOS
  ) do |nodes, roles, attr|
    nodes.select {|node|
      roles.include? node['role']
    }.uniq {|node|
      node['uid']
    }.map {|node|
      attr ? node[attr] : node
    }
  end
end

# vim: set ts=2 sw=2 et :

module Puppet::Parser::Functions
  newfunction(:nodes_with_roles, :type => :rvalue, :doc => <<-EOS
Return a list of nodes that have one of the given roles. If attr is defined,
return just that attribute for each node instead of the whole node hash.
EOS
  ) do |args|
    nodes, roles, attr = args
    nodes.select {|node|
      roles.include? node['role']
    }.uniq {|node|
      node['uid']
    }.map {|node|
      attr ? node[attr] : node
    }
  end
end

# vim: set ts=2 sw=2 et :

Fix ruby function args parsing
Fix ruby function args parsing

Change-Id: I3149ce42e2bdfacf30e4feb4300e69b3f33882f6
Closes-bug: #1268579
