summaryrefslogtreecommitdiff
path: root/lib/facter
diff options
context:
space:
mode:
authorJeff McCune <jeff@puppetlabs.com>2012-10-25 15:44:14 -0700
committerJeff McCune <jeff@puppetlabs.com>2012-10-25 15:44:14 -0700
commit43729e6ea9371b3335b8bbaf2fe0a5c09a3cd4a5 (patch)
tree4304339b93ca5a0ac044fc43add0b00f3378e0ec /lib/facter
parent2ce2c5bd8d138fcaf6485a6bd35c1da0f567b4d0 (diff)
downloadpuppet-stdlib-43729e6ea9371b3335b8bbaf2fe0a5c09a3cd4a5.tar.gz
puppet-stdlib-43729e6ea9371b3335b8bbaf2fe0a5c09a3cd4a5.tar.bz2
Revert "Revert "Merge branch '2.5.x' into 3.0.x""
This reverts commit 9e8c60a8b73fd96393b08d690c7197e62aae623e. This was an error on my part. 3.1.x descends from 3.0.x _and_ 2.5.x, but 3.0.x does not descend from 2.5.x. I should not have merged 2.5.x into 3.0.x, instead I should have merged 2.5.x into 3.1.x skipping over the 3.0.x merge up. I'm slowly starting to understand the implications of semver on our branching strategy... =)
Diffstat (limited to 'lib/facter')
-rw-r--r--lib/facter/pe_version.rb53
1 files changed, 53 insertions, 0 deletions
diff --git a/lib/facter/pe_version.rb b/lib/facter/pe_version.rb
new file mode 100644
index 0000000..0cc0f64
--- /dev/null
+++ b/lib/facter/pe_version.rb
@@ -0,0 +1,53 @@
+# 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
+ pe_ver = Facter.value("puppetversion").match(/Puppet Enterprise (\d+\.\d+\.\d+)/)
+ pe_ver[1] if pe_ver
+ 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