在厨师食谱中获取厨师食谱名称

Fetching Chef recipe name inside chef recipe

我有几个库函数,它们在给定食谱中的所有食谱中都很常见。因此,如果我提供配方名称,那些库函数可以对特定配方进行预期的行为更改。

与模板位置类似,配方特定模板存储在以配方命名的目录下。

现在在运行时在 chef 食谱中,如何确定 运行 食谱的名称,这可以让我利用上面的模板目录结构和库函数。

谢谢

使用recipe_name方法

Chef::Log.info("I am a message from the #{recipe_name} recipe in the #{cookbook_name} cookbook.")

来源:https://docs.chef.io/dsl_recipe.html#recipe-name