-
-
Save bmurtagh/0c3389e25837f76be17f to your computer and use it in GitHub Desktop.
Convert Chef Ruby DSL Roles to JSON
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'chef' | |
# Update path to reflect where your roles are stored | |
ROLE_DIR = "/Users/bmurtagh/chef-repo/roles" | |
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') | |
File.open(json_file, 'w'){|f| f.write(JSON.pretty_generate(role))} | |
end |
@bmurtagh - dude, you rock!
thanks for sharing! : )
The pain of going to chef_zero from chef-solo has just been eased a little bit.
This little script is getting some use 4 years later @bmurtagh. Thanks!
I expanded on it a bit further as well:
https://github.com/necrux/chef-tools/blob/master/convert-chef-role.rb
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
extremely helpful -- thanks!