Sha256: ff2f8fd852ed185001c05f4945a0de4d935b3aeb1c5b8aa7a3db1fc7daff40cf

Contents?: true

Size: 583 Bytes

Versions: 3

Compression:

Stored size: 583 Bytes

Contents

# Aggregates the key/value pairs in the results of a ResultSet into a hash
# mapping the keys to a hash of each distinct value and the list of nodes
# returning that value for the key.
Puppet::Functions.create_function(:'aggregate::nodes') do
  dispatch :aggregate_nodes do
    param 'ResultSet', :resultset
  end

  def aggregate_nodes(resultset)
    resultset.each_with_object({}) do |result, agg|
      result.value.each do |key, val|
        agg[key] ||= {}
        agg[key][val.to_s] ||= []
        agg[key][val.to_s] << result.target.name
      end
      agg
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bolt-0.17.2 modules/aggregate/lib/puppet/functions/aggregate/nodes.rb
bolt-0.17.1 modules/aggregate/lib/puppet/functions/aggregate/nodes.rb
bolt-0.17.0 modules/aggregate/lib/puppet/functions/aggregate/nodes.rb