2

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!

Philipp
  • 116
  • 4

2 Answers2

1

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
Leo Gallucci
  • 160
  • 9
  • Thx for your answer but this was not the problem i was looking to solve. i need a possibility to push (deploy) the cookbooks automated to the chef-server, the other steps seem to be solved by many. – Philipp Nov 27 '13 at 12:53
0

Just a comment: Foodcritic is not sufficient testing to move to production IMHO. Personally, I would want some form of Vagrant testing on a VM before any automated move to production.

However, that's your call not mine.

Ultimately, what you need to do is run a knife command somewhere. Either that's in Jenkins or in a process outside of Jenkins.

If you can't/don't want to run knife in Jenkins, then I would suggest using Jenkins to move the code between git branches. (i.e. Jenkins monitors the test branch and when code passes the tests, you use the git access to move it to the production branch.)

You would then need to build a process outside of Jenkins that more or less does what Jenkins does ( monitors a repository and takes action when it finds changes). Jenkins is very easy to setup, so if there are concerns about using the main server, you could run a "stand-alone" jenkins on a separate machine that just did the knife upload.

You aren't alone in this boat, everyone is struggling a bit with exactly how to create a chef workflow that works for their organization.