Details
-
Bug
-
Status: Accepted
-
Normal
-
Resolution: Unresolved
-
FACT 3.1.4
-
None
-
None
-
Platform OS
-
3
Description
A fact with an at_exit callback that uses the Facter module will fail with an uninitialized constant error.
We're using this code to enable some fact caching:
https://github.com/google/macops/blob/master/facter/cache.rb
In it, we have an at_exit handler to ensure updated cached values are written on exit. Since the handler tries to use Facter.debug and other methods, a NameError is raised.
A simpler code snippet to replicate this:
require 'facter'
|
|
at_exit { Facter.warn('Facter.warn at exit') }
|
at_exit { puts 'puts at exit' }
|
|
Facter.add('uninitialized_constant') do
|
setcode do
|
'foo'
|
end
|
end
|
This produces this output using facter 3:
$ sudo facter -p uninitialized_constant facterversion
|
facterversion => 3.1.4
|
uninitialized_constant => foo
|
puts at exit
|
/private/var/puppet/lib/facter/unint.rb:3:in `block in <top (required)>': uninitialized constant Facter (NameError)
|