Chef - share libraries between culinary specialists

Can I reuse 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

+4
source share
1 answer

This is possible with the help of chefs .

make sure the functions are defined in your namespace using 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, for example:

 myvar = Foo.very_useful_check 
+3
source

Source: https://habr.com/ru/post/1483589/


All Articles