This is a minimal "toplevel cookbook" example. A "toplevel cookbook" is the single top-level cookbook which represents a node. It may depend on other "library" or "application" cookbooks.
Note: this cookbook was previously (until v0.1.2) named sample-application-cookbook
, but since the term "application cookbook" is so much overloaded in the Chef community I now call them "top-level cookbooks".
In this case it's really nothing more than a templatable sample.html file served via apache.
It outputs the value of the node['sample_app']['words_of_wisdom']
attribute to the sample.html
file and optionally the items of the data bag named yummy
(if any).
It's meant as an example Chef cookbook and is also used for testing Bill's Kitchen which bundles ChefDK, Vagrant and Docker for the Windows platform.
All development dependencies are declared in the Gemfile
, which are mostly gems for cookbook testing, and we are testing on the following levels:
- ruby codestyle & liniting via rubocop
- chef linting via foodcritic
- unit tests via chefspec (using implicit receivers for crisper syntax)
- integration tests via test-kitchen / serverspec
- run
bundle install
to install the required gems fromGemfile
- run
rake -T
to see the available rake tasks for testing this cookbook - run
rake test
to run all unit-level tests, including syntax, foodcritic, codestyle and chefspec - run
rake integration
to run integration tests via test-kitchen / serverspec
- run
bundle exec kitchen converge
to bring up the sample-app in a local VM - visit http://localhost:8080/sample.html to check whether our sample app is deployed
- change the
:words_of_wisdom
attribute in .kitchen.yml, provision viabundle exec kitchen converge
and check the sample app again - run
bundle exec kitchen destroy
to terminate and delete the VM