ruby - Chef : Can I share common per-environment run list items?

标签 ruby deployment chef-infra

我在 Chef 中使用环境,我想使用每个环境的运行列表。问题是我不想重复自己(就像我现在做的那样)。示例:

{
  "name": "myapp",
  "default_attributes": {
  },
  "json_class": "Chef::Role",
  "env_run_lists": {
    "production": [
      # Has less packages because services are spread across specialized nodes
      "role[base]",
      "recipe[mysql::client]",
      "recipe[myapp]"
    ],
    "staging": [
      # Has less packages because services are spread across specialized nodes
      "role[base]",
      "recipe[mysql::client]",
      "recipe[myapp]"
    ],
    "development": [
      "role[base]",
      "recipe[mysql::client]",
      "recipe[myapp]",
      "role[utility]",
      "role[cache]"
    ]
  },
  "run_list": [

  ],
  "description": "The myapp.com core application role",
  "chef_type": "role",
  "override_attributes": {

  }
}

有什么方法可以避免重复此操作?

      "role[base]",
      "recipe[mysql::client]",
      "recipe[myapp]",

我只想避免环境运行列表不同步和破坏部署。

最佳答案

目前,没有。角色纯粹是声明性的,而不是动态的。您可以创建一个包含这三项的角色,并将其包含在每个环境的运行列表中。

关于ruby - Chef : Can I share common per-environment run list items?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9688959/

相关文章:

ruby - rails 中 Rubocop 哈希参数周围的冗余大括号

javascript - NextJS 的部署策略建议

sql - 如何从单独的脚本创建数据库?

chef-infra - 为什么 LWRP 自定义定义给了我未定义的方法 nil :NilClass

chef-infra - Chef - 如何在 Git 中存储加密数据包?

mysql - ld : library not found for -lzstd while bundle install for mysql2 gem Ruby on macOS Big Sur 11. 4

ruby-on-rails - 使用 CarrierWave、Rails 3 上传种子文件

git - 部署游戏!到 heroku

ruby - 无需 Chef 或 Knife 从 metadata.rb 生成 metadata.json

ruby-on-rails - rails 5 : How to import data in Elastic Search and perform conditional search?