Class: Helpers::Process

Inherits:
Object
  • Object
show all
Defined in:
lib/helpers/process.rb

Instance Method Summary collapse

Instance Method Details

#add_facts(facts, host) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/helpers/process.rb', line 4

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

#is_excluded?(fact) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/helpers/process.rb', line 25

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