什么是食谱?(What is a cookbook? and how is it used?)
有人可以向我解释一下食谱是什么以及我们如何在生产环境中使用它。
我看到使用厨师的人 - 食谱/ recepies他们使用什么和如何使用?
Can someone in plain please explain to me what a cookbook is and how we used it in a productionalized environment.
I see people using Chef - cookbooks/recepies what and how are they used?
原文:https://stackoverflow.com/questions/48830178
最满意答案
一些快速条款:
厨师资源 - 资源是对系统特定位的期望状态的描述。 像“应该安装包foo”或“文件/栏应该由root拥有”。
厨师食谱 - 将按顺序运行的一组资源,通常分组安装/管理某些特定的软件。
厨师食谱 - 一些食谱和其他文件(配置模板,默认属性值等)与一些主题分组,应作为一个单元发布和推广。
Some quick terms:
Chef resource – a resource is a description of the desired state of a particular bit of the system. Like "package foo should be installed" or "file /bar should be owned by root".
Chef recipe – a bunch of resources which will be run in order, usually grouped around installing/managing some particular piece of software.
Chef cookbook – a bunch of recipes and other files (config templates, default attribute values, etc) with some thematic grouping that should be released and promoted as a unit.
相关问答
更多-
我怀疑这与我们遇到的厨师有同样的问题。 它归结为运行时修订控制,而不是编译时修订控制。 获得的经验:在大规模运营厨师时,运行时无限制的食谱版本很危险。 背景 您正在使用Berkshelf管理您的cookbook依赖项,这很好,并将确保将正确的版本加载到Chef服务器中。 微妙的问题是每个食谱都有自己的依赖树。 在运行时,当您将多个cookbook添加到节点的运行列表时,Chef服务器必须计算一个新的依赖树。 问题可能看似随机,因为它取决于您在运行列表中的烹饪书组合。 烹饪书越多,冲突的可能性就越大。 我们尝 ...
-
您必须使用本地副本自行实现差异以进行幂等性跟踪。 总的来说,我建议将您的食谱重新设计为幂等的并且自己收敛。 You would have to implement the diff yourself using a local copy for idempotence tracking. Overall I would recommend reworking your recipes to be idempotent and convergent themselves.
-
目前还没有,除了一些手册require '../../../../othercookbook/test/integration/default/serverspec/other_spec'或类似的winkiness,这将取决于你碰巧使用的精确文件夹布局。 InSpec使这更容易,因为两个烹饪书都可以使用单个共享的InSpec测试配置文件。 Not currently, other than some manual require '../../../../othercookbook/test/integra ...
-
没有特定的方法,您需要编写一个新的配方来强制执行您想要的新状态(已卸载软件包,删除文件夹,停止服务等)。 There is no specific way, you would need to write a new recipe that enforces the new state you want (packages uninstalled, folders removed, services stopped, etc).
-
什么是食谱?(What is a cookbook? and how is it used?)[2021-10-12]
一些快速条款: 厨师资源 - 资源是对系统特定位的期望状态的描述。 像“应该安装包foo”或“文件/栏应该由root拥有”。 厨师食谱 - 将按顺序运行的一组资源,通常分组安装/管理某些特定的软件。 厨师食谱 - 一些食谱和其他文件(配置模板,默认属性值等)与一些主题分组,应作为一个单元发布和推广。 Some quick terms: Chef resource – a resource is a description of the desired state of a particular bit of ... -
那么,对于所描述的用例,我会做同样的事情。 Well, for the described use case, I would do the exact same.
-
include_recipe每次使用第一部分作为食谱名称。 所以你必须指定食谱 - 名字+食谱名称: include_recipe '::my_java' # works still after you rename your cookbook include_recipe 'base::my_java' # works only as long as your cookbook name is base include_recipe uses the first part every time as t ...
-
我试图构建的食谱非常复杂(elkstack),并要求用户在运行berks vendor之前手动编辑Berksfile 。 除非仔细计算出依赖关系,否则默认情况下会出现此挂起行为。 The cookbook I was trying to build is very complex (elkstack) and requires the user to manually edit Berksfile before running berks vendor. This hanging behavior is e ...
-
您需要在您的食谱的metadata.rb文件中定义您的依赖关系。 喜欢这个: depends 'poise-python' 对于这种特定的依赖关系,这足以使用它提供的自定义资源。 您应该查看任何依赖关系的README.md以获取使用它的指导。 你可以在这里找到poise-python的 。 你还应该检查它的依赖关系 ,以确保你有所有这些可用(上传到你的厨师服务器,或在厨师solo的cookbooks目录中)。 熟悉Policyfiles是为了更大规模地处理依赖关系。 You need to define ...
-
如何在Chef中编写带有外部cookbook_files的食谱?(How to write a cookbook with external cookbook_files in Chef?)[2021-08-09]
如果您希望通过cookbook_file资源访问该files ,则该文件应位于cookbook的files子目录中。 如果要从其他位置获取文件,则需要使用remote_file 。 (不要在你的食谱中设置node[:nginx][:ssl_file_location] 。) cookbook_file filename do [...] only_if { node[:nginx][:ssl_file_location].nil? } end remote_file ::File.join( no ...