blob: c9f2181c0d1c3b5d506ab6afe1fc9f8aab508d44 (
plain)
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
|
# Fact: is_pe, pe_version, pe_major_version, pe_minor_version, pe_patch_version
#
# Purpose: Return various facts about the PE state of the system
#
# Resolution: Uses a regex match against puppetversion to determine whether the
# machine has Puppet Enterprise installed, and what version (overall, major,
# minor, patch) is installed.
#
# Caveats:
#
Facter.add("pe_version") do
setcode do
puppet_ver = Facter.value("puppetversion")
if puppet_ver != nil
pe_ver = puppet_ver.match(/Puppet Enterprise (\d+\.\d+\.\d+)/)
pe_ver[1] if pe_ver
else
nil
end
end
end
Facter.add("is_pe") do
setcode do
if Facter.value(:pe_version).to_s.empty? then
false
else
true
end
end
end
Facter.add("pe_major_version") do
confine :is_pe => true
setcode do
if pe_version = Facter.value(:pe_version)
pe_version.to_s.split('.')[0]
end
end
end
Facter.add("pe_minor_version") do
confine :is_pe => true
setcode do
if pe_version = Facter.value(:pe_version)
pe_version.to_s.split('.')[1]
end
end
end
Facter.add("pe_patch_version") do
confine :is_pe => true
setcode do
if pe_version = Facter.value(:pe_version)
pe_version.to_s.split('.')[2]
end
end
end
|