Announce: chef-dk-template-plugin - easy distribution of ChefDK templates as gems


#1

Ohai Chefs!

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:

require 'chef-dk/template/plugin_base’
require ‘chef-dk/template/mixins’

the Chef Development Kit

module ChefDK

templates for ‘chef generate’

module Template
# a pluggable framework for distributing templates as ruby gems
class Plugin
# an example plugin for chef-dk-template-plugin
class Example < PluginBase
include ChefDK::Template::Mixin::CookbookBase

    # the version of the gem
    VERSION = '0.1.0'

    class << self
      def description
        'Example cookbook template'
      end
    end
  end
end

end
end

And you have a generator recipe like this:

template = ChefDK::Template::Plugin::Example.new(self)
template.generate

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

Cheers


#2

Great work team, looks super dope. Will be stoked to package up some
of our generator skels into gems and such.

IS NAICE

cheers,

–aj

On Tue, May 12, 2015 at 1:23 PM, FitzGibbon, James
James.I.FitzGibbon@nordstrom.com wrote:

Ohai Chefs!

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:

require 'chef-dk/template/plugin_base’
require ‘chef-dk/template/mixins’

the Chef Development Kit

module ChefDK

templates for ‘chef generate’

module Template
# a pluggable framework for distributing templates as ruby gems
class Plugin
# an example plugin for chef-dk-template-plugin
class Example < PluginBase
include ChefDK::Template::Mixin::CookbookBase

    # the version of the gem
    VERSION = '0.1.0'

    class << self
      def description
        'Example cookbook template'
      end
    end
  end
end

end
end

And you have a generator recipe like this:

template = ChefDK::Template::Plugin::Example.new(self)
template.generate

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

Cheers


#3

Seconded, great work!


Daniel DeLeo

On Monday, May 11, 2015 at 6:34 PM, AJ Christensen wrote:

Great work team, looks super dope. Will be stoked to package up some
of our generator skels into gems and such.

IS NAICE

cheers,

–aj

On Tue, May 12, 2015 at 1:23 PM, FitzGibbon, James
<James.I.FitzGibbon@nordstrom.com (mailto:James.I.FitzGibbon@nordstrom.com)> wrote:

Ohai Chefs!

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:

require 'chef-dk/template/plugin_base’
require ‘chef-dk/template/mixins’

the Chef Development Kit

module ChefDK

templates for ‘chef generate’

module Template

a pluggable framework for distributing templates as ruby gems

class Plugin

an example plugin for chef-dk-template-plugin

class Example < PluginBase
include ChefDK::Template::Mixin::CookbookBase

the version of the gem

VERSION = ‘0.1.0’

class << self
def description
’Example cookbook template’
end
end
end
end
end
end

And you have a generator recipe like this:

template = ChefDK::Template::Plugin::Example.new(self)
template.generate

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

Cheers


#4

Awesome stuff!

I was briefly looking into noe earlier, but this seems much more cheffish,
with all the flexibility you need…

Cheers, Torben
Am 12.05.2015 03:59 schrieb “Daniel DeLeo” dan@kallistec.com:

Seconded, great work!


Daniel DeLeo

On Monday, May 11, 2015 at 6:34 PM, AJ Christensen wrote:

Great work team, looks super dope. Will be stoked to package up some
of our generator skels into gems and such.

IS NAICE

cheers,

–aj

On Tue, May 12, 2015 at 1:23 PM, FitzGibbon, James
<James.I.FitzGibbon@nordstrom.com (mailto:
James.I.FitzGibbon@nordstrom.com)> wrote:

Ohai Chefs!

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:

require 'chef-dk/template/plugin_base’
require ‘chef-dk/template/mixins’

the Chef Development Kit

module ChefDK

templates for ‘chef generate’

module Template

a pluggable framework for distributing templates as ruby gems

class Plugin

an example plugin for chef-dk-template-plugin

class Example < PluginBase
include ChefDK::Template::Mixin::CookbookBase

the version of the gem

VERSION = ‘0.1.0’

class << self
def description
’Example cookbook template’
end
end
end
end
end
end

And you have a generator recipe like this:

template = ChefDK::Template::Plugin::Example.new(self)
template.generate

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

Cheers


#5

Ohai again.

At Chef’s request, I have renamed this framework so as to not pollute the ChefDK namespace.

I hereby present: chef-gen-flavors. That’s as cute as I’m willing to go. :slight_smile:

New repos:

https://github.com/Nordstrom/chef-gen-flavors

https://github.com/Nordstrom/chef-gen-flavor-example

I also uploaded a transitional version of the chef-dk-template-plugin gem that nags you about the rename if you happened to jump on board first. Sorry for the mixup, I should have floated the name choice here before releasing.

Cheers

From: , James FitzGibbon <james.i.fitzgibbon@nordstrom.commailto:james.i.fitzgibbon@nordstrom.com>
Date: Monday, May 11, 2015 at 6:23 PM
To: "chef-dev@lists.opscode.commailto:chef-dev@lists.opscode.com" <chef-dev@lists.opscode.commailto:chef-dev@lists.opscode.com>
Subject: Announce: chef-dk-template-plugin - easy distribution of ChefDK templates as gems

Ohai Chefs!

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:

require 'chef-dk/template/plugin_base’
require ‘chef-dk/template/mixins’

the Chef Development Kit

module ChefDK

templates for ‘chef generate’

module Template
# a pluggable framework for distributing templates as ruby gems
class Plugin
# an example plugin for chef-dk-template-plugin
class Example < PluginBase
include ChefDK::Template::Mixin::CookbookBase

    # the version of the gem
    VERSION = '0.1.0'

    class << self
      def description
        'Example cookbook template'
      end
    end
  end
end

end
end

And you have a generator recipe like this:

template = ChefDK::Template::Plugin::Example.new(self)
template.generate

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

Cheers