DEV: Update facter usage

`Facter.reset` (65d167eac9/lib/facter.rb (L126-L137)) clears `Facter::Options[:external_dir]` which seems to be the 4.x equivalent of `Facter::Util::Config.external_facts_dirs`.

This commit also makes sure that version 4.0 or higher is installed.
This commit is contained in:
Jarek Radosz 2020-05-30 01:03:40 +02:00
parent 8c8391c742
commit 4babdf510b
1 changed files with 2 additions and 3 deletions

View File

@ -68,10 +68,9 @@ end
begin
require 'facter'
raise LoadError if Gem::Version.new(Facter.version) < Gem::Version.new("4.0")
rescue LoadError
run "gem install facter"
# Facter requires CFPropertyList, but doesn't install it.
run "gem install CFPropertyList"
puts "please rerun script"
exit
end
@ -286,7 +285,7 @@ begin
# Prevent using external facts because it breaks when running in the
# discourse/discourse_bench docker container.
Facter::Util::Config.external_facts_dirs = []
Facter.reset
facts = Facter.to_hash
facts.delete_if { |k, v|