Skip to content

lakim/ruby-chef-box

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ruby Chef box

This project is a base configuration to run a Ruby project both in development with Vagrant and in production.

It uses Chef to provision the server.

Pre-requisites

Install Vagrant: http://docs.vagrantup.com/v2/installation/ Install Virtual Box: https://www.virtualbox.org/wiki/Downloads

gem install berkshelf
vagrant plugin install vagrant-omnibus
vagrant plugin install vagrant-berkshelf

Usage

The recommended way is to use this kitchen as a git submodule. Here is a good example of project structure:

my_project/
  chef/
    kitchen/ (submodule https://github.com/lakim/ruby-chef-box.git)
    app-cookbooks/ (project specific cookbooks)
    nodes/
  Vagrantfile
  Berksfile
cd my_project
git submodule add https://github.com/lakim/ruby-chef-box.git chef/kitchen
cp chef/kitchen/Berksfile.sample Berksfile
cp chef/kitchen/Vagrantfile.sample Vagrantfile
vagrant up
vagrant ssh

On the VM:

sudo su deploy
echo "source /etc/profile.d/rbenv.sh" >> ~/.bashrc
bash
rbenv versions

If the previous steps were fine, you should get a list of installed Ruby versions. Then go for some tests:

cd /vagrant
gem install bundler
gem install rails
rbenv rehash
rails new .

Postgresql

Default user/password: postgres/postgres

To generate a password:

echo -n 'my_password''postgres' | openssl md5 | sed 's/^.* //' | sed 's/^/md5/'

Test postgresql connection:

psql --username=postgres --password --host=localhost

Using Vagrant snapshots

Taking snapshots of your Vagrant VM can save you a lot of time, especially when you experimenting. Vagrant comes with a build in snapshot engine, which can be controlled from the command line thanks to this plugin : https://github.com/dergachev/vagrant-vbox-snapshot

On your host:

vagrant plugin install vagrant-vbox-snapshot

Here are the most usefull commands, from the plugin page:

vagrant snapshot take [NAME]            # take snapshot, labeled by NAME
vagrant snapshot list                   # list snapshots
vagrant snapshot back                   # restore last taken snapshot
vagrant snapshot delete [NAME]          # delete specified snapshot
vagrant snapshot go [NAME]				# restore specified snapshot

Remember you can also manage snapshots using Vagrant GUI.

TODO

  • Fix rbenv PATH for deploy user
  • Use UNIX socket for postgres instead of TCP connection
  • Do not configure gems doc by default

About

Ruby development and production box with Vagrant and Chef

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages