ChefDK cookbook generator question

Hey all,

I’m in the midst of creating a custom cookbook generator and would like to
set some of the generator options while still allowing them to be
overridden when passed in from the command line. Thus far, I’ve been doing
something like this within recipes/cookbook.rb:

context = ChefDK::Generator.context
context.copyright_holder = ‘Example, Inc.’

While that works, if I specify -C at the command line, eg. chef generate
cookbook test_cookbook -C ‘Other, Inc.’, I can’t override the
copyright_holder option set in cookbook.rb. Is there somewhere better to
set these options so that any passed from the command line would take
precedence without directly modifying the defaults set in chef-dk/lib/
chef-dk/command/generator_commands.rb?

Thanks,
Nick

Ohai Chefs!

Recently I also faced with issue about cookbook generating and updating
existing cookbooks.
After googling I've found interesting project Noe:

  1. http://revision-zero.org/noe
  2. GitHub - blambeau/noe: Noe is a simple, general-purpose and extensible skeleton generator from project templates

I tried to use it and it works for me. Really cool. I'm still not using
ChefDK and this project also doesn't depend on ChefDK.

Creating templates and using it now easy.
Check this out: GitHub - jsirex/chef-cookbook.noe: Noe skeleton for Chef Cookbook

noe prepare --template=chef-cookbook --layout=short my-cookbook
cd my-cookbook

Edit specific information about your cookbook

edit my-cookbook.noespec

Let Noe generate your project

noe go

Let Noe update your project after some time

noe go --safe-override

Let Noe regenerate noespec (if new version has changed specs)

noe prepare --template=chef-cookbook --layout=short --force

Note: template still in very beta state.

2015-02-16 19:33 GMT+03:00 Nick Shemonsky n.shemonsky@gmail.com:

Hey all,

I'm in the midst of creating a custom cookbook generator and would like to
set some of the generator options while still allowing them to be
overridden when passed in from the command line. Thus far, I've been doing
something like this within recipes/cookbook.rb:

context = ChefDK::Generator.context
context.copyright_holder = 'Example, Inc.'

While that works, if I specify -C at the command line, eg. chef generate
cookbook test_cookbook -C 'Other, Inc.', I can't override the
copyright_holder option set in cookbook.rb. Is there somewhere better to
set these options so that any passed from the command line would take
precedence without directly modifying the defaults set in chef-dk/lib/
chef-dk/command/generator_commands.rb?

Thanks,
Nick