0

Is there a way to use Linux locate in Chef/ruby to find required files?

Preferred is elegant way.

I have shell_out example in my head. I know that I can do it with Ohai. Better suggestions? It's important to write each line to array as well. Any help on this?

locate = shell_out('locate -e gcc')

if locate.exitstatus == 0 && locate
Chef::Log.info("Locate results: #{locate.stdout}")
end
laimison
  • 1,409
  • 3
  • 17
  • 39
  • What's the underlying problem you want to solve? Finding out if gcc is installed and if so, where? – matt freake Mar 18 '16 at 18:29
  • We have decided to use locate in our company to increase chef-client run. The purpose is to find required binaries which are not packages via Chef. Shortly, the path is needed. So in our example 'gcc' should be not a package and sitting anywhere on the file system. – laimison Mar 18 '16 at 18:42
  • 1
    What are you planning to do with this information? Generally you wouldn't need to know the path to gcc for anything. – coderanger Mar 18 '16 at 20:05
  • The next step will be to remove OR to remove and install newest version as a package. This affects not only gcc, but the principal is the same. It is simple question how to find the files on the file system. – laimison Mar 21 '16 at 11:09

0 Answers0