Skip to content

Instantly share code, notes, and snippets.

@yatskevich
Last active December 22, 2015 20:39
Show Gist options
  • Save yatskevich/6527892 to your computer and use it in GitHub Desktop.
Save yatskevich/6527892 to your computer and use it in GitHub Desktop.
Chef + Berkshelf + Vagrant

Install Chef (chef-client, chef-solo, knife)

curl -L https://www.opscode.com/chef/install.sh | sudo bash

Use knife-solo

Use Berkshelf

  • generate application cookbook using Berkshelf
  • add gem 'knife-solo' to generated Gemfile
  • create .chef/knife.rb and add role_path "roles", otherwise knife-solo won't copy roles to a server
  • use 'bundle exec knife solo' for all knife-solo commands

Step 1. Install Berkshelf

gem install berkshelf

# optional
rbenv rehash

Step 2. Download and install Vagrant

Step 3. Go to vagrantbox.es and choose required box.

Step 4. Add Vagrant box

vagrant box add opscode-ubuntu-10.04 http://opscode-vagrant-boxes.s3.amazonaws.com/ubuntu10.04-gems.box

Step 5. Download and install VirtualBox

Research VMWare option later

Step 6. Install Vagrant Berkshelf plugin (to provision boxes using Chef + Berkshelf)

vagrant plugin install vagrant-berkshelf

Step 7. Generate fresh Chef cookbook with Chef / Berkshelf / Vagrant support

berks cookbook <app-name>

Doing more...

Step 8. Use Foodcritic - a lint tool for your Opscode Chef cookbooks.

gem install foodcritic

or adjust Step 7:

berks cookbook <app-name> --foodcritic

Sources: Berkshelf official docs, Vagrant official docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment