我正试图了解 Chef ,但我终其一生都找不到 cooking 书是如何运作的
如果我有文件结构
chef-repo
├── cookbooks
│ └── test
│ ├── attributes
│ │ ├── default.rb
│ │ └── test.rb
│ ├── files...
│ ├── metadata.rb
│ ├── recipes
│ │ ├── default.rb
│ │ └── test.rb
│ └── templates...
├── roles
│ └── starter.rb
└── Vagrantfile
如何加载属性以及加载顺序?例如,它加载所有属性(default.rb 和 test.rb),并且 default.rb 始终首先加载
Recipe 是如何运行的?例如,仅运行 default.rb 并且所有内容或所有内容均按字母顺序运行。
我找到了 http://docs.opscode.com/essentials_nodes_chef_run.html但它并没有解释 Recipe 执行仅节点级执行。任何资源或指向 Chef 文档的链接将不胜感激
干杯
最佳答案
配方按照它们在运行列表中出现的顺序运行。只有出现在运行列表中的配方才会被执行(加上使用 include_recipe
包含的任何配方。请注意,每个配方只会运行一次,即使它在运行列表中出现多次也是如此。
Recipe 中的属性文件按以下顺序加载:
- 依赖属性(即在
metadata.rb
中使用depends
声明的 Recipe ) attributes/default.rb
- 所有其他
attributes
文件按字母顺序排列。
请注意, Recipe 中的所有属性文件都会被加载,无论它们的名称如何。只有在已解析的运行列表中明确出现的 Recipe 属性(即由角色加载的 Recipe 或明确包含在运行列表中)或者是其 Recipe 的依赖项才会被加载。
关于ruby - Chef Recipe 的执行顺序是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23318279/