From 3b887c880c8850ee9fce5531bd36f946a8c82512 Mon Sep 17 00:00:00 2001 From: Jeff McCune Date: Mon, 6 May 2013 16:29:35 -0700 Subject: (#20582) Restore facter_dot_d to stdlib for PE users Without this patch Puppet Enterprise users who install the most recent version of stdlib lose the ability to resolve certain facts critical to the operation of Puppet Enterprise. These facts are defined externally in the file `/etc/puppetlabs/facter/facts.d/puppet_enterprise_installer.txt`. As an example, Puppet Enterprise catalogs fail to compile if the `fact_stomp_server`, and `fact_stomp_port` facts are not defined. `facter_dot_d` was removed from stdlib version 4 because Facter version 1.7 now supports external facts defined in `/etc/puppetlabs/facter/facts.d/puppet_enterprise_installer.txt`. Puppet Enterprise does not yet include Facter 1.7, however. The most recent PE release, 2.8.1, includes Facter 1.6.17. With this version of Facter, users who replace the version of stdlib that ships with PE with the most recent version from the Forge will lose the ability to resolve facts from `/etc/puppetlabs/facter/facts.d/puppet_enterprise_installer.txt`. This patch addresses the problem by detecting if Facter version < 1.7 is loaded. If so, then the facter_dot_d.rb facts will be defined using the stdlib custom fact. If Facter >= 1.7 is being used then stdlib will not define external facts. --- lib/facter/facter_dot_d.rb | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/lib/facter/facter_dot_d.rb b/lib/facter/facter_dot_d.rb index 3e528ab..634a397 100644 --- a/lib/facter/facter_dot_d.rb +++ b/lib/facter/facter_dot_d.rb @@ -181,12 +181,22 @@ class Facter::Util::DotD end end -Facter::Util::DotD.new("/etc/facter/facts.d").create -Facter::Util::DotD.new("/etc/puppetlabs/facter/facts.d").create - -# Windows has a different configuration directory that defaults to a vendor -# specific sub directory of the %COMMON_APPDATA% directory. -if Dir.const_defined? 'COMMON_APPDATA' then - windows_facts_dot_d = File.join(Dir::COMMON_APPDATA, 'PuppetLabs', 'facter', 'facts.d') - Facter::Util::DotD.new(windows_facts_dot_d).create + +mdata = Facter.version.match(/(\d+)\.(\d+)\.(\d+)/) +if mdata + (major, minor, patch) = mdata.captures.map { |v| v.to_i } + if major < 2 + # Facter 1.7 introduced external facts support directly + unless major == 1 and minor > 6 + Facter::Util::DotD.new("/etc/facter/facts.d").create + Facter::Util::DotD.new("/etc/puppetlabs/facter/facts.d").create + + # Windows has a different configuration directory that defaults to a vendor + # specific sub directory of the %COMMON_APPDATA% directory. + if Dir.const_defined? 'COMMON_APPDATA' then + windows_facts_dot_d = File.join(Dir::COMMON_APPDATA, 'PuppetLabs', 'facter', 'facts.d') + Facter::Util::DotD.new(windows_facts_dot_d).create + end + end + end end -- cgit v1.2.3