I would like to announce the first release of chef-dk-template-plugin, a stab at making it easy to distribute custom ChefDK templates inside and outside of your organization.
Here’s a brief demo. Let’s assume you have a plugin class like this:
the Chef Development Kit
templates for ‘chef generate’
# a pluggable framework for distributing templates as ruby gems
# an example plugin for chef-dk-template-plugin
class Example < PluginBase
# the version of the gem VERSION = '0.1.0' class << self def description 'Example cookbook template' end end end end
And you have a generator recipe like this:
template = ChefDK::Template::Plugin::Example.new(self)
Now when you run ‘chef generate cookbook foo’, you’ll get a cookbook that has all the things provided by the ‘CookbookBase’ mixin (things like a README, CHANGELOG, metadata.rb, etc.)
Because the generators are Ruby classes:
you can extend, inherit and metaprogram them to your heart’s delight
you can test them using RSpec or minitest or Aruba/Cucumber
you can create mixins for other people to use
you can distribute your mixins or templates as ruby gems
you can update them using ‘chef gem install’
My hope is that this will spur more sharing of good cookbook practice while still allowing you to compose templates that meet the various needs you have inside your organization.
Feedback and PRs are welcome.
Plugin Framework: https://github.com/Nordstrom/chef-dk-template-plugin
Example Plugin: https://github.com/Nordstrom/chef-dk-template-example