diff options
author | Rick Bradley <rick@rickbradley.com> | 2010-12-12 20:10:53 -0600 |
---|---|---|
committer | Daniel Pittman <daniel@rimspace.net> | 2011-01-31 11:23:58 -0800 |
commit | b88a088c6e53ef96914280e6937b9b9214b6c64b (patch) | |
tree | 6c07ee88a921caee62d88e3a0bb8cdcb3efbdeed /lib | |
parent | d9b8f2ad68626b8655d98a8d9037283f671f86bb (diff) | |
download | facter-b88a088c6e53ef96914280e6937b9b9214b6c64b.tar.gz facter-b88a088c6e53ef96914280e6937b9b9214b6c64b.tar.xz facter-b88a088c6e53ef96914280e6937b9b9214b6c64b.zip |
(#5510) Facter should load custom fact definitions in filename order.
Ruby's Dir.entries will return files in different orders depending on
the OS and/or filesystem. As a result Facter::Util::Loader will load
ruby custom fact definitions in different orders on different platforms.
Specs to expose the bugs, and code to ensure that custom fact files are
loaded in alphabetical order.
Addresses redmine issue #5510
http://projects.puppetlabs.com/issues/5510
Signed-off-by: Rick Bradley <rick@rickbradley.com>
Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/facter/util/loader.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/facter/util/loader.rb b/lib/facter/util/loader.rb index ac90c48..2d2d9e8 100644 --- a/lib/facter/util/loader.rb +++ b/lib/facter/util/loader.rb @@ -30,7 +30,7 @@ class Facter::Util::Loader search_path.each do |dir| next unless FileTest.directory?(dir) - Dir.entries(dir).each do |file| + Dir.entries(dir).sort.each do |file| path = File.join(dir, file) if File.directory?(path) load_dir(path) @@ -62,7 +62,7 @@ class Facter::Util::Loader def load_dir(dir) return if dir =~ /\/\.+$/ or dir =~ /\/util$/ or dir =~ /\/lib$/ - Dir.entries(dir).find_all { |f| f =~ /\.rb$/ }.each do |file| + Dir.entries(dir).find_all { |f| f =~ /\.rb$/ }.sort.each do |file| load_file(File.join(dir, file)) end end |