cookbook 'generator-cookbook', '~> 0.1.0'
generator-cookbook (1) Versions 0.1.0 Follow0
Installs / configures generated_cookbook
cookbook 'generator-cookbook', '~> 0.1.0', :supermarket
knife supermarket install generator-cookbook
knife supermarket download generator-cookbook
Chef Generator Cookbook
Generator cookbook for creating new cookbooks using chef generate cookbook COOKBOOK_NAME --generator-cookbook
. Checkout [test/desired_cookbook/
](./test/desired_cookbook/) to see how a generated cookbook will look.
Usage
- Download the cookbook available from Chef Supermarket
- Generate a cookbook using
chef generate cookbook ...
fromchef-dk
, passing in the path to this generator-cookbook as an argument
# download the cookbook from the supermarket curl -L https://supermarket.chef.io/cookbooks/generator-cookbook/download | tar xz # install `chef` utility from chef-dk if you don't already have it which chef || gem install chef-dk --no-document # generate your new cookbook using the generator repo as a template chef generate cookbook COOKBOOK_NAME \ --copyright 'Copyright Holder' \ --email 'email@domain.com' \ --license 'apachev2' \ --generator-cookbook generator-cookbook
Differences from default generator
- Each generated file includes a simple code example to get you started in that file
- Test-kitchen and Chefspec Travis CI setup generated
- Gemfile generated
- This generator always uses Berkshelf rather than Policyfile
- There is no Chef Delivery support
Here is a comparison of the file trees created by this generator and the default chef-dk generator:
this_generator/ default_chef-dk_generator/
.gitignore .gitignore
.kitchen.docker.yml .kitchen.yml
.kitchen.yml Berksfile
.rspec LICENSE
.travis.sh README.md
.travis.yml chefignore
Berksfile metadata.rb
Gemfile recipes/
LICENSE default.rb
README.md spec/
attributes/ spec_helper.rb
default.rb unit/
chefignore recipes/
metadata.rb default_spec.rb
recipes/ test/
default.rb integration/
spec/ default/
recipes/ default_test.rb
default_spec.rb
spec_helper.rb 7 directories, 11 files
test/
fixtures/
cookbooks/
fixture_cookbook/
metadata.rb
recipes/
default.rb
integration/
default/
default_spec.rb
11 directories, 19 files
Development
Generating with this cookbook is tested in Travis - a cookbook is generated and then compared to [test/desired_cookbook
](./test/desired_cookbook/).
When developing the generator cookbook, its handy to run the generator and see if your changes work as you intended:
# clear generated_cookbook/ and generate into it rm -rf generated_cookbook bundle exec chef generate cookbook generated_cookbook \ --copyright 'Copyright Holder' \ --email 'email@domain.com' \ --license 'apachev2' \ --verbose \ --generator-cookbook . # compare the file trees of test/desired_cookbook/ and generated_cookbook/ mkdir -p tmp tree -aF test/desired_cookbook > tmp/desired_cookbook.tree tree -aF generated_cookbook > tmp/generated_cookbook.tree git diff --no-index tmp/*.tree # diff the contents of test/desired_cookbook/ and generated_cookbook/ git diff --no-index test/desired_cookbook generated_cookbook
Releasing
Ensure your local master
branch is up to date with changes and metadata version increase. Then use stove
to create and push a git tag and the push cookbook to the supermarket.
bundle exec stove --username atheiman --key ~/.chef/atheiman-chef.io.pem
Dependent cookbooks
This cookbook has no specified dependencies.
Contingent cookbooks
There are no cookbooks that are contingent upon this one.
Collaborator Number Metric
0.1.0 failed this metric
Failure: Cookbook has 0 collaborators. A cookbook must have at least 2 collaborators to pass this metric.
Foodcritic Metric
0.1.0 passed this metric
No Binaries Metric
0.1.0 passed this metric
0.1.0 failed this metric
0.1.0 passed this metric
No Binaries Metric
0.1.0 passed this metric
0.1.0 passed this metric