diff options
author | Jeff McCune <jeff@puppetlabs.com> | 2012-10-25 12:01:01 -0700 |
---|---|---|
committer | Jeff McCune <jeff@puppetlabs.com> | 2012-10-25 12:01:01 -0700 |
commit | 4004a758b0c01ac17206a838f91f8cf5c57cc466 (patch) | |
tree | 4304339b93ca5a0ac044fc43add0b00f3378e0ec /lib/facter | |
parent | fb8993bf48ba6e6baeb1f2b1987262a287285965 (diff) | |
parent | 1d371ab8b67b85d52f8c4932f78660de8a236b93 (diff) | |
download | puppet-stdlib-4004a758b0c01ac17206a838f91f8cf5c57cc466.tar.gz puppet-stdlib-4004a758b0c01ac17206a838f91f8cf5c57cc466.tar.bz2 |
Merge branch '3.1.x' into 3.x
* 3.1.x:
Update Modulefile, CHANGELOG for 3.1.0
Revert "Revert "Revert "Merge branch 'hkenney-ticket/master/2157_remove_facts_dot_d'"""
Update Modulefile, CHANGELOG for 2.5.0
Explicitly load functions used by ensure_resource
re-formatting
Add better docs about duplicate resource failures
Handle undef for parameter argument
Add function ensure_resource and defined_with_params
Revert "Revert "Merge branch 'haus-add_pe_facts_to_stdlib' into 2.4.x""
Revert "Revert "Merge branch 'haus-add_pe_facts_to_stdlib' into 2.4.x""
Revert "Merge branch 'haus-add_pe_facts_to_stdlib' into 2.4.x"
Prevent undefined method `split' for nil:NilClass with pe_foo_version facts
(maint) Clear all facts before each example
Add spec tests for pe_version facts
Add PE facts to stdlib
Fix some logical inconsistencies in README
(#14422) Update README to include the bug tracker URL.
Revert "Revert "Merge branch 'hkenney-ticket/master/2157_remove_facts_dot_d'""
Diffstat (limited to 'lib/facter')
-rw-r--r-- | lib/facter/pe_version.rb | 53 |
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 |