Skip to content

Instantly share code, notes, and snippets.

@miketheman
Created August 2, 2012 12:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miketheman/3236753 to your computer and use it in GitHub Desktop.
Save miketheman/3236753 to your computer and use it in GitHub Desktop.
CHEF-3345 Repro
require 'chef/role'
# The gist files name role-* should be moved into a directory named 'roles'.
role_path = Chef::Config[:role_path] = "./roles"
Dir.glob(File.join(role_path, '*.{rb,json}')) do |role_file|
rolefilename = File.basename(role_file, File.extname(role_file))
role = Chef::Role.from_disk(rolefilename)
puts role.inspect
puts role.class
end
role[rbrole]
Chef::Role
{"name"=>"jsonrole", "description"=>"Sample json role", "run_list"=>["recipe[ntp]"]}
Hash
{
"name" : "jsonrole",
"description" : "Sample json role",
"run_list" : ["recipe[ntp]"]
}
name "rbrole"
description "Some ruby role"
run_list("recipe[ntp]")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment