Expose the location of your home directory
Facter will automatically search for extra facts in all of Ruby's search paths. Create a ruby library directory in your home directory:
mkdir -p ~/lib/ruby/facter
And then add it to your Ruby search path:
export RUBYLIB=$RUBYLIB:~/lib/ruby
Lastly, create this file at ~/lib/ruby/facter/home.rb:
require 'facter'
Facter.add("home") do
setcode do
ENV['HOME']
end
end
It is now available as a fact:
luke@culain(0) $ facter home
/home/luke
luke@culain(0) $