Skip to content

Instantly share code, notes, and snippets.

@mrded
Last active December 20, 2015 21:59
Show Gist options
  • Save mrded/6201762 to your computer and use it in GitHub Desktop.
Save mrded/6201762 to your computer and use it in GitHub Desktop.
Vagrant box for Ruby on Rails
#!/usr/bin/env ruby
#^syntax detection
site 'http://community.opscode.com/api/v1'
cookbook 'apt'
cookbook 'build-essential'
cookbook 'git'
cookbook 'mysql'
cookbook 'postgresql' #:github => 'express42-cookbooks/postgresql'
cookbook 'zsh'
cookbook 'rubygems'
cookbook 'rvm', :git => 'git://github.com/fnichol/chef-rvm.git'
cookbook 'redis', :git => 'git://github.com/fnichol/chef-redis.git'
cookbook 'oh_my_zsh', :git => 'git://github.com/shingara/oh-my-zsh-chef.git'
# cookbooks/mysql/recipes/default.rb
# Create databases.
['development', 'test'].each do |name|
execute "create database #{name}" do
command "mysql -uroot -p#{node[:mysql][:server_root_password]} -e 'create database if not exists #{name}'"
user "vagrant"
end
end
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant::Config.run do |config|
config.vm.box = "lucid32"
config.vm.box_url = "http://files.vagrantup.com/lucid32.box"
config.vm.forward_port 3000, 3000
# mysql
config.vm.forward_port 3306, 3306
# postgresql
config.vm.forward_port 5432, 5432
config.vm.provision :chef_solo do |chef|
chef.cookbooks_path = ["cookbooks"]
chef.add_recipe "apt"
chef.add_recipe "build-essential"
chef.add_recipe "git"
chef.add_recipe "rvm::vagrant"
chef.add_recipe "rvm::system"
chef.add_recipe 'rubygems'
chef.add_recipe "mysql::server"
chef.add_recipe "postgresql::server"
chef.add_recipe "redis"
chef.add_recipe "zsh"
chef.add_recipe "oh_my_zsh"
chef.json.merge!({
:rvm => {
:default_ruby => 'ruby-2.0.0-p247'
},
:rubygems => { :version => "2.0.0" },
:postgresql => {
'password' => {
'postgres' => 'root'
}
},
:mysql => {
"server_root_password" => "root",
"server_repl_password" => "root",
"server_debian_password" => "root",
"allow_remote_root" => true
},
:oh_my_zsh => {
:users => [{
:login => 'vagrant',
:theme => 'arrow',
:plugins => ['gem', 'git', 'rails3', 'redis-cli', 'ruby']
}]
},
:run_list => ["recipe[postgresql::server]"]
})
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment