Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm using Vagrant + Chef (chef_client provisioner) to create & provision a staging environment for my server. And I have a Jenkins job set up that is run every time I push to my 'develop' branch.

In the Jenkins job, I would like to update & rebuild the source code of the server in the staging box and restart it.

I have already written the cookbooks that install the dependencies, configure the db etc. But I'm not sure how to run only the update & rebuild & restart stuff from the cookbooks. I understand I could always tear down the whole box and rebuild it, but provisioning the box is a lengthy process so I would like to do that as little as possible.

I split my server cookbook into 3 recipes: dependencies, db_setup and server. What I want to run in the my Jenkins job is the "server" recipe only. But I dont' understand how can I do that... If I specify the run_list on my Chef server, then I lose the ability to provision the whole box from scratch.

Basically, I would like to be able to tell Vagrant from the command line what recipes Chef should run. Is that possible somehow?

Cheers!

share|improve this question
add comment

1 Answer

Chef resources are supposed to be idempotent so you should be able to run chef-client over and over without having software re-installed unless there is actually a change that you want. You can create your chef-recipe to only do a new build of the code if there is a change from the last time it was run.

So you can have a recipe that only does the update & rebuild if there is a change and then in the rebuild part you can do a notifies :restart on all of the relevant services (that is the process I am following right now).

See this answer for more details on idempotence and repetetive invocations of chef http://stackoverflow.com/questions/4913521/chef-repetitive-recipe-execution

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.