Debugging facts

You can debug Facter by using a facter.debug statement anywhere in your custom fact's Ruby code, as shown in the following:

Facter::Type.newtype(:mycustomfact) do
...
Facter.debug "foo is the value: #{foo}"
...
end

During debugging, running Facter by itself won't pick up your new custom fact since it would usually require the pluginsync process to distribute it. You must set the FACTERLIB environment variable to shortcut this process when you are developing and debugging the new code on your development node. Let's say you have the some_facts and some_other_facts subdirectories in your personal working directory, where you are editing the Ruby code for a new fact you are developing. You would set the code up as follows:

$ ls ~/some_facts
mycustomfact.rb
$ ls ~/some_other_facts
myothercustomfact.rb
$ export FACTERLIB="~/some_facts: ~/some_other_facts"
$ facter mycustomfact myothercustomfact –debug
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.189.178.237