Is it possible to reuse the code from a cookbook library in another cookbook provider/library?
cookbook1/libraries/lib.rb
    ...
    def very_useful_check
      true
    end
    ...
cookbook2/libraries(providers?)/foo.rb
...
myvar = very_useful_check
...
thanks
It's possible by using Chef Libraries.
make sure the functions are defined in your namespace via ruby modules:
module Foo
  def very_useful_check
    true
  end
end
class Chef::Recipe::namespace
  include Foo
end
Then you can use it in any recipe like:
myvar = Foo.very_useful_check
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With