Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I'm using environments in chef, and I want to use per-environment run lists. The problems is that I don't want to repeat myself (like I'm doing now). Example:

{
  "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": {

  }
}

Is there a way I can avoid repeating this?

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

I just want to avoid environment run lists falling out of sync and breaking deployments.

like image 219
Kenny Avatar asked Mar 13 '12 17:03

Kenny


1 Answers

At this time, no. Roles are purely declarative and not dynamic in that way. You could create a role that includes those three items and include that in the per environment run lists.

like image 143
jtimberman Avatar answered Sep 20 '22 05:09

jtimberman