Posts

Showing posts from March, 2012

Cookbook Testing using Vagrant

There came a time in our team where we started churning out cookbooks by the hour. Now the question that needed to be answered was - How does one QA a chef cookbook. We could either have had one team member solely responsible for writing out rspecs and testing the cookbooks on a virtual environment, but what happens when the only team members who can be used to perform the above task as busy creating the cookbooks themselves. We needed a faster and smoother answer. In came Vagrant. Well Vagrant does everything that one would need to do to set up a virtual environment without wasting time in installations, snapshots, teardowns etc. Vagrant gives us one file "Vagrantfile" that needs to be configured with the environment that needs to be set and voila! everything works like you want it to. The standard (read easiest) way to use vagrant is as below. Create a directory where you want to store all your vagrant data, I call it vagrant. Then download the boxes that you need in y...

Deploy Application via Chef

After creating the Ruby on Rails application mentioned in my blog , the next task was to deploy the application to a hosted web server. The traditional way would be to write rake tasks and trigger them manually or using a CI build/deploy. Well chef provides another easy solution to deploy an application. The recipe below performs all the tasks of deploying an application. The before_migrate script contains the tasks that need to be performed before the application kicks in. The migration_command is the final command that is run to mark deployment successful. deploy_revision is used to make sure that the recipe would only be executed once the git head changes in the repository from the last deployed version. symlink_before_migrate can be used to create symlinks to the yml files used in the configuring the application. The deploy cookbook for a basic app looks like below app_user="user" deploy_dir="/opt/application_deploy" user app_user directory "/home...