Is it possible to confine a custom fact to the existence of a specific command?
Please consider the question as it is laid down and ignore the fact that I used bash in the example.
Facter.add("bash_version") do
# fact only runs if command (bash in this case) exists
confine :true.which('bash')
setcode do
%x{bash --version | grep -E 'bash.*version' | cut -d ' ' -f 4 | cut -d '-' -f 1}.chomp
end
end
↧