-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
Copy pathfacter_impl.rb
96 lines (77 loc) · 1.64 KB
/
facter_impl.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# frozen_string_literal: true
#
# @api private
# Default Facter implementation that delegates to Facter API
#
module Puppet
class FacterImpl
def initialize
require 'facter'
setup_logging
end
def value(fact_name)
::Facter.value(fact_name)
end
def add(name, &block)
::Facter.add(name, &block)
end
def to_hash
::Facter.to_hash
end
def clear
::Facter.clear
end
def reset
::Facter.reset
end
def resolve(options)
::Facter.resolve(options)
end
def search_external(dirs)
::Facter.search_external(dirs)
end
def search(*dirs)
::Facter.search(*dirs)
end
def trace(value)
::Facter.trace(value) if ::Facter.respond_to? :trace
end
def debugging(value)
::Facter.debugging(value) if ::Facter.respond_to?(:debugging)
end
def load_external?
::Facter.respond_to?(:load_external)
end
def load_external(value)
::Facter.load_external(value) if self.load_external?
end
private
def setup_logging
return unless ::Facter.respond_to? :on_message
::Facter.on_message do |level, message|
case level
when :trace, :debug
level = :debug
when :info
# Same as Puppet
when :warn
level = :warning
when :error
level = :err
when :fatal
level = :crit
else
next
end
Puppet::Util::Log.create(
{
:level => level,
:source => 'Facter',
:message => message
}
)
nil
end
end
end
end