Create custom fact for linux service
Hello,
I am trying to create a custom fact for linux service. If service exists then custom fact is created. If service does not exist then pass. I am able to get this by using file existence check. But would like to see if better way is possible? Here is existing code.
Facter.add(:service_test) do confine :osfamily => "RedHat" setcode do if File.exist? '/etc/init.d/test' 'test' end end end
there are a couple suggestions here: https://stackoverflow.com/questions/24398242/check-if-service-exists-in-bash-centos-and-ubuntu but i think checking for a files existence seems pretty resonable. what about checking the files existence do you see as problematic?