Skip to content

Instantly share code, notes, and snippets.

@tobami
tobami / chef-roles-to-json-task.rb
Created February 21, 2011 08:11 — forked from timdiggins/chef-roles-to-json-task.rb
Chef ruby roles to json
# ADD this to Rakefile and run it by issuing rake roles.to_json
ROLE_DIR = File.expand_path(File.join(TOPDIR, "roles"))
namespace :roles do
desc "Convert ruby roles from ruby to json, creating/overwriting json files."
task :to_json do
Dir.glob(File.join(ROLE_DIR, '*.rb')) do |rb_file|
role = Chef::Role.new
role.from_file(rb_file)
json_file = rb_file.sub(/\.rb$/,'.json')