Using Ruby DSL for Environments or Roles

Chef-Zero doesn’t support Environments/Roles which written by Ruby DSL.

Although I do not usually write roles or others using ruby. But you can convert them by knife.rb at every knife run.

Dir.glob("roles/*.rb").each do |rf|
  role =, ".rb"))
  role.from_file(rf)".rb", ".json"),"w") {|f| f.puts(role.to_json)}

local_mode true
chef_repo_path File.expand_path("../", __FILE__)

## -- snip --

Please keep in mind that this usage becomes the target outside of knife edit other for normal workflow commands.

I recommend to add JSON files to .gitignore when you use this little hack.

Fork me on GitHub