Skip to content

Instantly share code, notes, and snippets.

@timdiggins
timdiggins / chef-roles-to-json-task.rb
Created February 19, 2011 06:53
rake task to convert existing 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')
Process: ruby [4332]
Path: /usr/bin/ruby
Identifier: ruby
Version: ??? (???)
Code Type: X86 (Native)
Parent Process: zsh [327]
Date/Time: 2009-05-15 11:15:29.213 +0100
OS Version: Mac OS X 10.5.6 (9G55)
Report Version: 6
Process: ruby [1079]
Path: /usr/bin/ruby
Identifier: ruby
Version: ??? (???)
Code Type: X86 (Native)
Parent Process: zsh [327]
Date/Time: 2009-05-13 14:26:58.435 +0100
OS Version: Mac OS X 10.5.6 (9G55)
Report Version: 6