Skip to content

Instantly share code, notes, and snippets.

@MarkRoddy
Created February 12, 2013 19:49
Show Gist options
  • Save MarkRoddy/4772809 to your computer and use it in GitHub Desktop.
Save MarkRoddy/4772809 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
require 'rubygems'
gem 'chef', ">= 0"
require 'chef/role'
if 1 != ARGV.length then
print "Please specify a role name or path to it's ruby file\n"
exit
end
role_name_or_path = ARGV[0];
if File.exists?(role_name_or_path) then
role_path = role_name_or_path
else
role_path = "roles/#{role_name_or_path}.rb"
end
role = Chef::Role.new
role.from_file(role_path)
print Chef::JSONCompat.to_json_pretty(role)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment