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
|
# File 'lib/puppet/node/server_facts.rb', line 4
def self.load
server_facts = {}
pe_version_file = '/opt/puppetlabs/server/pe_version'
if File.readable?(pe_version_file) and !File.zero?(pe_version_file)
server_facts['pe_serverversion'] = File.read(pe_version_file).chomp
end
server_facts["serverversion"] = Puppet.version.to_s
{ "servername" => "networking.fqdn",
"serverip" => "networking.ip",
"serverip6" => "networking.ip6" }.each do |var, fact|
value = Puppet.runtime[:facter].value(fact)
unless value.nil?
server_facts[var] = value
end
end
if server_facts["servername"].nil?
host = Puppet.runtime[:facter].value('networking.hostname')
if host.nil?
Puppet.warning _("Could not retrieve fact servername")
elsif domain = Puppet.runtime[:facter].value('networking.domain') server_facts["servername"] = [host, domain].join(".")
else
server_facts["servername"] = host
end
end
if server_facts["serverip"].nil? && server_facts["serverip6"].nil?
Puppet.warning _("Could not retrieve either serverip or serverip6 fact")
end
server_facts
end
|