Just in case anybody come across this post, I've used the following successfully:
require 'facter'
Facter.add('host_role') do
setcode do
location = case Facter.value(:hostname)
when /home/ then $&
else 'unknown'
end
Q%[This is a #{location} server]
end
end
I'm sure this can be done more elegantly but for now, it will work.