Chef cookbook continuous deployment

chefcontinuous integrationJenkins

I'm trying to integrate my chef workflow to my usual continuous integration/deployment workflows.

I managed already to have a jenkins task which checks out the git repo and runs foodcritic but i can't figure out the last step: to push to cookbook to the chef server.

some ideas i thought of:

  • use knife: the problem is, that on the building nodes of my jenkins-server there is no knife installed and AFAIK knife needs a cookbook directory from which it would push the cookbook. On the other side i don't consider it a good practice to let the jenkins user execute all knife commands
  • use the knife ruby-gem and write some ruby-script to be used by jenkins: might work but i didn't want to experiment with that, because i don't think it is the best option anyway
  • make some REST-API calls with cURL or any similar library. After reading through the API-docs i don't think it's worth the hassle to implement that.

My the building node would be available as OSX and debian – if this is essential for my possible tool of choice.

So any experience would be appreciated!

Best Answer

If you want to push the cookbook to a chef server just for testing purposes, perhaps you will be better with chef-zero which is a "fast-start in-memory Chef server for testing and solo purposes".

Or, if you are just trying to test the cookbooks you can run the whole test without a chef server by using test-kitchen + minitest-chef-handler. I would suggest you don't use the "bats" but instead follow the minitest-chef-handler test cases examples

Serverfault Note: I still can't post more that 2 links for being a new member so try to follow them below:

minitest-chef-handler
  github: calavera/minitest-chef-handler

bats
  github: test-kitchen/test-kitchen/wiki/Getting-Started

test cases examples
  github: calavera/minitest-chef-handler#test-cases