Skip to content

Commit

Permalink
Setup automatic virtual server provisioning with vagrant and chef
Browse files Browse the repository at this point in the history
* install and configure vagrant gem
* install and configure librarian gem
* add mongodb-debs cookbook
* add rails-lastmile cookbook
* update README
  • Loading branch information
potomak committed Jul 19, 2012
1 parent d10b488 commit 2d84201
Show file tree
Hide file tree
Showing 26 changed files with 617 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -7,3 +7,4 @@ config/github.yml
config/twitter.yml
.DS_Store
public/assets
cookbooks/
1 change: 1 addition & 0 deletions .vagrant
@@ -0,0 +1 @@
{"active":{"default":"851c4939-651b-499c-b6d9-77d5cd98f848"}}
25 changes: 25 additions & 0 deletions Cheffile
@@ -0,0 +1,25 @@
#!/usr/bin/env ruby
#^syntax detection

site 'http://community.opscode.com/api/v1'

# cookbook 'chef-client'

# cookbook 'apache2', '>= 1.0.0'

# cookbook 'rvm',
# :git => 'https://github.com/fnichol/chef-rvm'

# cookbook 'postgresql',
# :git => 'https://github.com/findsyou/cookbooks',
# :ref => 'postgresql-improvements'

cookbook 'ruby_build',
:git => 'git://github.com/fnichol/chef-ruby_build.git', :ref => 'v0.6.0'
cookbook 'rbenv',
:git => 'https://github.com/fnichol/chef-rbenv', :ref => 'v0.6.4'
cookbook 'apt',
:git => 'https://github.com/fnichol/chef-apt'

cookbook 'nginx'
cookbook 'vim'
44 changes: 44 additions & 0 deletions Cheffile.lock
@@ -0,0 +1,44 @@
SITE
remote: http://community.opscode.com/api/v1
specs:
bluepill (1.0.6)
build-essential (1.1.0)
nginx (0.101.6)
bluepill (>= 0.0.0)
build-essential (>= 0.0.0)
ohai (~> 1.0.2)
runit (>= 0.0.0)
yum (>= 0.0.0)
ohai (1.0.2)
runit (0.15.0)
vim (1.0.2)
yum (0.6.2)

GIT
remote: git://github.com/fnichol/chef-ruby_build.git
ref: v0.6.0
sha: f5eae16a199571d15f151f118338b3b11c42f694
specs:
ruby_build (0.6.0)

GIT
remote: https://github.com/fnichol/chef-apt
ref: master
sha: cb998dfdeffbcbb6805527b046b411206d6c77d6
specs:
apt (1.2.0)

GIT
remote: https://github.com/fnichol/chef-rbenv
ref: v0.6.4
sha: 4e87a6d477cb6d675eed060e46910cb88d3f4448
specs:
rbenv (0.6.4)

DEPENDENCIES
apt (>= 0)
nginx (>= 0)
rbenv (>= 0)
ruby_build (>= 0)
vim (>= 0)

7 changes: 7 additions & 0 deletions Gemfile
Expand Up @@ -54,6 +54,9 @@ gem 'omniauth-twitter'
# Thin
gem 'thin'

# Unicorn
gem 'unicorn'

# New Relic
gem 'newrelic_rpm'

Expand All @@ -69,4 +72,8 @@ gem 'merit'
group :development, :test do
gem 'heroku'
gem 'mocha'

# Virtual box provisioning with vagrant and librarian gems
gem 'vagrant'
gem 'librarian'
end
25 changes: 25 additions & 0 deletions Gemfile.lock
Expand Up @@ -30,6 +30,7 @@ GEM
multi_json (~> 1.0)
addressable (2.2.7)
ambry (0.3.1)
archive-tar-minitar (0.5.2)
arel (3.0.2)
asset_sync (0.4.2)
activemodel
Expand All @@ -54,6 +55,8 @@ GEM
multi_json (~> 1.0)
faraday (0.8.1)
multipart-post (~> 1.1)
ffi (0.6.3)
rake (>= 0.8.7)
fog (1.4.0)
builder
excon (~> 0.14.0)
Expand Down Expand Up @@ -86,13 +89,17 @@ GEM
actionpack (>= 3.0.0)
activesupport (>= 3.0.0)
railties (>= 3.0.0)
kgio (2.7.4)
launchy (2.1.0)
addressable (~> 2.2.6)
librarian (0.0.4)
thor
libv8 (3.3.10.4)
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mario (0.0.6)
merit (0.8.1)
ambry (~> 0.3.0)
metaclass (0.0.1)
Expand Down Expand Up @@ -156,6 +163,7 @@ GEM
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
raindrops (0.10.0)
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
Expand Down Expand Up @@ -187,6 +195,20 @@ GEM
uglifier (1.2.4)
execjs (>= 0.3.0)
multi_json (>= 1.0.2)
unicorn (4.3.1)
kgio (~> 2.6)
rack
raindrops (~> 0.7)
vagrant (0.5.4)
archive-tar-minitar (= 0.5.2)
erubis (>= 2.6.6)
json (>= 1.4.3)
mario (~> 0.0.6)
net-scp (>= 1.0.2)
net-ssh (>= 2.0.19)
virtualbox (~> 0.7.3)
virtualbox (0.7.9)
ffi (~> 0.6.3)

PLATFORMS
ruby
Expand All @@ -199,6 +221,7 @@ DEPENDENCIES
heroku
jquery-rails
kaminari
librarian
merit
mocha
mongoid
Expand All @@ -211,3 +234,5 @@ DEPENDENCIES
therubyracer
thin
uglifier (>= 1.0.3)
unicorn
vagrant
17 changes: 12 additions & 5 deletions README.md
Expand Up @@ -6,11 +6,18 @@ Try it for free at [http://tomato.es](http://tomato.es "Tomatoes")

## Why?

Because

1. the [Pomodoro technique](http://www.pomodorotechnique.com)<sup>®</sup> helps you to get things done;
2. I need it to measure pomodoros in a fast and easy way;
3. I want to challenge my friends.
1. [Pomodoro technique](http://www.pomodorotechnique.com)<sup>®</sup> helps you to get things done.
1. I need it to measure pomodoros in a fast and easy way.
1. I want to get motivated by challenging my friends.

## How to setup a development virtual server with Virtualbox

1. Install Virtualbox (see https://www.virtualbox.org/wiki/Downloads).
1. Fork the project on github and clone the repo.
1. Run `bundle install` to install required gems.
1. Run `librarian-chef` to install required cookbooks.
1. Run `vagrant up` to start a virtual machine containing the app (this process can take a few minutes).
1. Open http://localhost:8080 on your browser.

## License

Expand Down
106 changes: 106 additions & 0 deletions Vagrantfile
@@ -0,0 +1,106 @@
Vagrant::Config.run do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.

# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "lucid32"

# The url from where the 'config.vm.box' box will be fetched if it
# doesn't already exist on the user's system.
config.vm.box_url = "http://files.vagrantup.com/lucid32.box"

# Boot with a GUI so you can see the screen. (Default is headless)
# config.vm.boot_mode = :gui

# Assign this VM to a host-only network IP, allowing you to access it
# via the IP. Host-only networks can talk to the host machine as well as
# any other machines on the same network, but cannot be accessed (through this
# network interface) by any external networks.
# config.vm.network :hostonly, "192.168.33.10"

# Assign this VM to a bridged network, allowing you to connect directly to a
# network using the host's network device. This makes the VM appear as another
# physical device on your network.
# config.vm.network :bridged

# Forward a port from the guest to the host, which allows for outside
# computers to access the VM, whereas host only networking does not.
config.vm.forward_port 80, 8080

# Share an additional folder to the guest VM. The first argument is
# an identifier, the second is the path on the guest to mount the
# folder, and the third is the path on the host to the actual folder.
# config.vm.share_folder "v-data", "/vagrant_data", "../data"

# Enable provisioning with Puppet stand alone. Puppet manifests
# are contained in a directory path relative to this Vagrantfile.
# You will need to create the manifests directory and a manifest in
# the file base.pp in the manifests_path directory.
#
# An example Puppet manifest to provision the message of the day:
#
# # group { "puppet":
# # ensure => "present",
# # }
# #
# # File { owner => 0, group => 0, mode => 0644 }
# #
# # file { '/etc/motd':
# # content => "Welcome to your Vagrant-built virtual machine!
# # Managed by Puppet.\n"
# # }
#
# config.vm.provision :puppet do |puppet|
# puppet.manifests_path = "manifests"
# puppet.manifest_file = "base.pp"
# end

# Enable provisioning with chef solo, specifying a cookbooks path, roles
# path, and data_bags path (all relative to this Vagrantfile), and adding
# some recipes and/or roles.

config.vm.provision :chef_solo do |chef|
chef.cookbooks_path = ["cookbooks", "site-cookbooks"]

chef.add_recipe "apt"
chef.add_recipe "ruby_build"
chef.add_recipe "rbenv::system"
chef.add_recipe "rbenv::vagrant"
chef.add_recipe "nginx"
chef.add_recipe "mongodb-debs"
chef.add_recipe "rails-lastmile"

chef.json = {
'rvm' => {
'default_ruby' => 'ruby-1.9.2-p290',
'gem_package' => {
'rvm_string' => 'ruby-1.9.2-p290'
}
}
}
end

# Enable provisioning with chef server, specifying the chef server URL,
# and the path to the validation key (relative to this Vagrantfile).
#
# The Opscode Platform uses HTTPS. Substitute your organization for
# ORGNAME in the URL and validation key.
#
# If you have your own Chef Server, use the appropriate URL, which may be
# HTTP instead of HTTPS depending on your configuration. Also change the
# validation key to validation.pem.
#
# config.vm.provision :chef_client do |chef|
# chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"
# chef.validation_key_path = "ORGNAME-validator.pem"
# end
#
# If you're using the Opscode platform, your validator client is
# ORGNAME-validator, replacing ORGNAME with your organization name.
#
# IF you have your own Chef Server, the default validation client name is
# chef-validator, unless you changed the configuration.
#
# chef.validation_client_name = "ORGNAME-validator"
end
34 changes: 34 additions & 0 deletions site-cookbooks/mongodb-debs/README.rdoc
@@ -0,0 +1,34 @@
= DESCRIPTION:

Installs mongodb from debian pacakges based on the instructions from
http://www.mongodb.org/display/DOCS/Ubuntu+and+Debian+packages

= REQUIREMENTS:

== Platform:

Tested on Ubuntu 10.04, Debian Lenny.

= USAGE:

Include the mongodb-debs recipe to install mongodb on your system:

include_recipe "mongodb-debs"

= LICENSE and AUTHOR:

Author:: Marius Ducea (marius@promethost.com)

Copyright:: 2010, Promet Solutions

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
10 changes: 10 additions & 0 deletions site-cookbooks/mongodb-debs/metadata.rb
@@ -0,0 +1,10 @@
maintainer "Promet Solutions"
maintainer_email "marius@promethost.com"
license "Apache 2.0"
description "Installs MongoDB"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc'))
version "0.2.0"

%w{ ubuntu debian }.each do |os|
supports os
end
35 changes: 35 additions & 0 deletions site-cookbooks/mongodb-debs/recipes/default.rb
@@ -0,0 +1,35 @@
#
# Author:: Marius Ducea (marius@promethost.com)
# Cookbook Name:: mongodb
# Recipe:: default
#
# Copyright 2010, Promet Solutions
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

include_recipe "mongodb-debs::repo"

package "mongodb-10gen"

service "mongodb" do
action [ :enable, :start ]
end

template "/etc/mongodb.conf" do
source "mongodb.conf.erb"
owner "root"
group "root"
mode 0644
notifies :restart, resources(:service => "mongodb")
end

0 comments on commit 2d84201

Please sign in to comment.