Skip to content

Instantly share code, notes, and snippets.

@nicholasklick
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicholasklick/af98d5814d5b8ba6d844 to your computer and use it in GitHub Desktop.
Save nicholasklick/af98d5814d5b8ba6d844 to your computer and use it in GitHub Desktop.
Sets up a basic install of Chef solo, vagrant and berkshelf
# =====================
# INITIAL PROJECT SETUP
# =====================
#
# Create basic project directory
mkdir try-chef
cd try-chef
#
# Create Gemfile which is used by Bundler
cat Gemfile
source "https://rubygems.org"
gem 'chef'
gem 'knife-solo'
gem 'berkshelf'
#
# Install all gems
bundle install
#
# Create kitchen directory structure
knife solo init .
#
# Create Berkfile which is used by Berkshelf
cat Berksfile
site :opscode
cookbook 'rbenv'
#
# Install all cookbooks and their dependencies to /cookbooks dir
berks install
# =============
# VIRTUAL BOX + VAGRANT SETUP
# =============
# Install VirtualBox: https://www.virtualbox.org/wiki/Downloads
# Install Vagrant: http://www.vagrantup.com/downloads
#
# Generate Vagrantfile which configs Vagrant
vagrant init precise64
#
# Start up the VM
vagrant up
#
# Attempt to login to the box
vagrant ssh
# ==================================
# NOW GO CONFIGURE YOUR CHEF REPO !!
# ==================================
# =============
# CHEF COMMANDS
# =============
#
# Boostrap the server with basic chef configuration and performs first run
knife solo bootstrap -p 2222 vagrant@localhost
# Enter 'vagrant' when prompted for the password for `vagrant@localhost`.
# You will have to do this like 9-10 times
#
# SSH into the box, assumes that a `deploy` user was created
# and you either have the password for the `deploy` user or by installing an ssh key
# ssh -p 2222 vagrant@localhost also works using `vagrant` as the password
ssh -p 2222 deploy@localhost
# After making any changes to our chef repo push the changes to the node, assumes you have a `deploy` user setup
knife solo cook -p 2222 deploy@localhost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment