ruby - Chef Recipe 的执行顺序是什么

标签 ruby chef-infra chef-recipe cookbook

我正试图了解 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 中的属性文件按以下顺序加载:

  1. 依赖属性(即在 metadata.rb 中使用 depends 声明的 Recipe )
  2. attributes/default.rb
  3. 所有其他 attributes 文件按字母顺序排列。

请注意, Recipe 中的所有属性文件都会被加载,无论它们的名称如何。只有在已解析的运行列表中明确出现的 Recipe 属性(即由角色加载的 Recipe 或明确包含在运行列表中)或者是其 Recipe 的依赖项才会被加载。

关于ruby - Chef Recipe 的执行顺序是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23318279/

相关文章:

ruby-on-rails - Rails 回调检查记录是否存在,否则返回 404

chef-infra - 如何在 Chef ruby​​_block 中要求我的图书馆

javascript - Rails 服务器因多次 js 调用而崩溃

ruby-on-rails - 在 ruby​​ on Rails 中的 Controller 操作之间共享数据

chef-infra - 关于设置 Chef 推送作业的任何指示?

linux - 使用数据包对资源 `install` 执行操作 'newrelic_agent_infrastructure[Install]' 时出错

ruby - 如何设置对在 Chef 加载 Recipe 时不存在的 Ruby 库的依赖项?

ruby-on-rails - 须藤标准输出 : unicorn_appname_production: unrecognized service

mysql - 如何使用 mysql Recipe ?