Sha256: 0817d9c1578e5aa81f1f0d9e9d054932812713af1cf166e8e65f3f50167cc787

Contents?: true

Size: 890 Bytes

Versions: 1

Compression:

Stored size: 890 Bytes

Contents

class Helpers::Process

  def add_facts(facts, host)

    fact_collection = { host => {} }
    facts.each{|f|
      if f['certname'].eql?(host)
        fact_name = f['name']
        fact_value = f['value']

        if fact_name.include?('hostname')
          fact_value = host
        end

        if !is_excluded?(fact_name)
          fact_collection[host][fact_name] = fact_value
        end

      end
    }
    return fact_collection
  end

  def is_excluded?(fact)

    excluded_facts = [
      '^processor(s|\d+)$', '^path$', '^utc_offset$', '^os$',
      '^ec2_metrics_vhostmd$', '^ec2_network_interfaces_macs.*',
      '^ec2_userdata$', '^ec2_metadata$',
      '^partitions$', '^system_uptime$', '^apt_package_updates$'
    ]

    match = false
    for ex in excluded_facts
      if fact.match(ex)
        match = true
        break;
      end
    end

    return match
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
puppetdb_rundeck-1.0.0 lib/helpers/process.rb