[Pkg-puppet-devel] [SCM] Packaging of Facter for debian branch, experimental_upstream, updated. 1.5.9-54-g5a4eeed
James Turnbull
james at lovedthanlost.net
Wed Jun 22 08:51:49 UTC 2011
The following commit has been merged in the experimental_upstream branch:
commit 9f4c5c6ac79821700bf4e6beee81f3d865396f4b
Author: Richard Clamp <richardc at unixbeard.net>
Date: Fri Mar 11 12:23:23 2011 +0000
(#6740) facter doesn't always respect facts in environment variables
On an OSX host:
$ facter operatingsystem
Darwin
$ facter_operatingsystem=Not_Darwin facter operatingsystem
Not_Darwin
But on a linux/solaris host:
$ facter operatingsystem
CentOS
$ facter_operatingsystem=Not_CentOS facter operatingsystem
CentOS
As the operatingsystem fact resolution for linux-based kernels has higher
precedence than the environment variable as it has more matching confines than
the value from the environment variable.
This patch adds from_environment to the resolution mechanism, which makes the
resolution have an artificially high weight by claiming the length of its
confines array is 1 billion.
diff --git a/lib/facter/util/loader.rb b/lib/facter/util/loader.rb
index 2d2d9e8..b6aa8de 100644
--- a/lib/facter/util/loader.rb
+++ b/lib/facter/util/loader.rb
@@ -90,6 +90,7 @@ class Facter::Util::Loader
next if fact and env_name != fact
Facter.add($1) do
+ from_environment
setcode { value }
end
diff --git a/lib/facter/util/resolution.rb b/lib/facter/util/resolution.rb
index 4a99c35..2ca2447 100644
--- a/lib/facter/util/resolution.rb
+++ b/lib/facter/util/resolution.rb
@@ -85,17 +85,29 @@ class Facter::Util::Resolution
end
end
+ # Say this resolution came from the environment
+ def from_environment
+ @from_environment = true
+ end
+
# Create a new resolution mechanism.
def initialize(name)
@name = name
@confines = []
@value = nil
@timeout = 0
+ @from_environment = false
end
# Return the number of confines.
def length
- @confines.length
+ # If the resolution came from an environment variable
+ # say we're very very sure about the value of the resolution
+ if @from_environment
+ 1_000_000_000
+ else
+ @confines.length
+ end
end
# We need this as a getter for 'timeout', because some versions
--
Packaging of Facter for debian
More information about the Pkg-puppet-devel
mailing list