Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding vagrant, bundler, and foreman.
- Loading branch information
Kale Worsley
committed
Feb 2, 2012
1 parent
4388fad
commit 3a5a261
Showing
19 changed files
with
345 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
RAILS_ENV=development | ||
RAILS_PORT=3000 | ||
|
||
SPHINX_PORT=9999 | ||
SPHINX_CONFIG=./config/development.sphinx.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,3 +30,4 @@ Gemfile.lock | |
*.swp | ||
*.swo | ||
GeoLiteCity.dat | ||
.vagrant |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
source :rubygems | ||
source "http://gems.github.com/" | ||
|
||
gem "ambethia-smtp-tls", "1.0", :require => "smtp-tls", :path => 'vendor/gems/ambethia-smtp-tls-1.0' | ||
gem "ancestry", "1.2.3", :require => "ancestry", :path => 'vendor/gems/ancestry-1.2.3' | ||
gem "aws-s3", "0.6.2", :require => "aws/s3", :path => 'vendor/gems/aws-s3-0.6.2' | ||
gem "babosa", "0.3.5" | ||
gem "bluecloth", "2.1.0" | ||
gem "builder", "2.1.2" | ||
gem "carlosparamio-geoplanet", "0.2.2", :require => "geoplanet", :path => 'vendor/gems/carlosparamio-geoplanet-0.2.2' | ||
gem "columnize", "0.3.4" | ||
gem "daemon-spawn", "0.4.2", :require => "daemon_spawn" | ||
gem "daemons", "1.1.4" | ||
gem "dbf", "1.2.9" | ||
gem "delayed_job", "2.0.3" | ||
gem "delayed_paperclip", "0.6.5", :path => 'vendor/gems/delayed_paperclip-0.6.5' | ||
gem "fastercsv", "1.5.4" | ||
gem "flickraw", "0.8.3", :path => 'vendor/gems/flickraw-0.8.3' | ||
gem "friendly_id", "3.2.1.1" | ||
gem "hoptoad_notifier", "2.3.3", :path => 'vendor/gems/hoptoad_notifier-2.3.3' | ||
gem "hpricot", "0.8.4" | ||
gem "htmlentities", "4.0.0", :path => 'vendor/gems/htmlentities-4.0.0' | ||
gem "i18n", "0.5.0" | ||
gem "json", "1.6.1" | ||
gem "koala", "1.1.0" | ||
gem "mime-types", "1.17.1", :require => "mime/types" | ||
gem "mojombo-chronic", "0.3.0", :require => "chronic", :path => 'vendor/gems/mojombo-chronic-0.3.0' | ||
gem "multi_json", "1.0.3" | ||
gem "multipart-post", "1.1.3" | ||
gem "nofxx-georuby", "1.9.2", :require => "geo_ruby" | ||
gem "nokogiri", "1.4.7" | ||
gem "objectify-xml", "0.2.3", :require => "objectify_xml" | ||
gem "omniauth", "0.2.6" | ||
gem "paperclip", "2.3.8", :path => 'vendor/gems/paperclip-2.3.8' | ||
gem "pg", "0.11.0" | ||
gem "preferences", "0.4.2" | ||
gem "rack", "1.1.2" | ||
gem "rails", "2.3.12" | ||
gem "rdoc" | ||
gem "rest-client", "1.6.7", :require => "rest_client" | ||
gem "riddle", "1.4.0" | ||
gem "rubyist-aasm", "2.0.2", :require => "aasm", :path => 'vendor/gems/rubyist-aasm-2.0.2' | ||
gem "spatial_adapter", "1.3.1" | ||
gem "thinking-sphinx", "1.4.6", :require => "thinking_sphinx" | ||
gem "ts-delayed-delta", "1.1.1", :require => "thinking_sphinx/deltas/delayed_delta" | ||
gem "tzinfo", "0.3.30" | ||
gem "will_paginate", "2.3.15" | ||
gem "xml-simple", "1.0.12", :require => "xmlsimple", :path => 'vendor/gems/xml-simple-1.0.12' | ||
|
||
group :development, :test do | ||
gem "foreman" | ||
gem "machinist", "1.0.6" | ||
gem "mocha", "0.9.4", :path => 'vendor/gems/mocha-0.9.4' | ||
gem "faker", "1.0.1" | ||
gem "ruby-debug", "0.10.4" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
web: ./script/server --environment=$RAILS_ENV --port=$RAILS_PORT | ||
shpinx: searchd --console --port $SPHINX_PORT --config $SPHINX_CONFIG | ||
worker: bundle exec rake jobs:work |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# -*- mode: ruby -*- | ||
# vi: set ft=ruby : | ||
|
||
Vagrant::Config.run do |config| | ||
|
||
# Every Vagrant virtual environment requires a box to build off of. | ||
config.vm.box = "puppet-squeeze-64" | ||
|
||
# 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://puppetlabs.s3.amazonaws.com/pub/squeeze64.box" | ||
|
||
# Boot with a GUI so you can see the screen. (Default is headless) | ||
config.vm.boot_mode = :gui | ||
|
||
config.vm.forward_port 3000, 3000 | ||
|
||
# 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 inaturalist.pp in the manifests_path directory. | ||
# | ||
config.vm.provision :puppet do |puppet| | ||
puppet.manifests_path = "vagrant/manifests" | ||
puppet.module_path = "vagrant/modules" | ||
puppet.manifest_file = "inaturalist.pp" | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
begin | ||
require "rubygems" | ||
require "bundler" | ||
rescue LoadError | ||
raise "Could not load the bundler gem. Install it with `gem install bundler`." | ||
end | ||
|
||
if Gem::Version.new(Bundler::VERSION) <= Gem::Version.new("0.9.24") | ||
raise RuntimeError, "Your bundler version is too old for Rails 2.3." + | ||
"Run `gem install bundler` to upgrade." | ||
end | ||
|
||
begin | ||
# Set up load paths for all bundled gems | ||
ENV["BUNDLE_GEMFILE"] = File.expand_path("../../Gemfile", __FILE__) | ||
Bundler.setup | ||
rescue Bundler::GemNotFound | ||
raise RuntimeError, "Bundler couldn't find some gems." + | ||
"Did you run `bundle install`?" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
include apt | ||
include postgresql | ||
|
||
# The sources.list that ships with the vagrant box is no good, so just | ||
# clobber it. | ||
file { "/etc/apt/sources.list": | ||
ensure => absent, | ||
} | ||
apt::source { "security": | ||
source => "deb http://security.debian.org/ squeeze/updates main contrib non-free", | ||
require => File["/etc/apt/sources.list"], | ||
} | ||
apt::primary_mirror {"nz": | ||
require => Apt::Source["security"], | ||
before => Package["postgresql-8.4"], | ||
} | ||
|
||
# Make sure the apt mirro is set up before any packages are installed | ||
#Package <| |> -> Apt::Primary_mirror["nz"] | ||
|
||
package {"postgresql-8.4-postgis": require => Package["postgresql-8.4"]} | ||
postgresql::db { "template_postgis": | ||
is_template => true, | ||
user => 'vagrant', | ||
encoding => "UTF8", | ||
require => [Postgresql::User["vagrant"], Package["postgresql-8.4-postgis"]] | ||
} | ||
postgresql::language { "plpgsql": | ||
database => "template_postgis", | ||
require => Postgresql::Db["template_postgis"], | ||
} | ||
postgresql::sqlfile { "/usr/share/postgresql/8.4/contrib/postgis-1.5/postgis.sql": | ||
database => "template_postgis", | ||
require => Postgresql::Language["plpgsql"], | ||
unless => "/usr/bin/psql -tA --command '\\df st_spheroid_in' template_postgis | grep -q st_spheroid_in", | ||
} | ||
postgresql::sqlfile { "/usr/share/postgresql/8.4/contrib/postgis-1.5/spatial_ref_sys.sql": | ||
database => "template_postgis", | ||
require => Postgresql::Sqlfile["/usr/share/postgresql/8.4/contrib/postgis-1.5/postgis.sql"], | ||
unless => "/usr/bin/psql -tA --command 'SELECT srid FROM spatial_ref_sys WHERE srid = 3819' template_postgis | grep -q 3819", | ||
} | ||
postgresql::user { "vagrant": | ||
createdb => true, | ||
password => 'vagrant', | ||
require => Package["postgresql-8.4"] | ||
} | ||
postgresql::db {["inaturalist_development", "inaturalist_test"]: | ||
template => "template_postgis", | ||
owner => 'vagrant', | ||
user => 'vagrant', | ||
encoding => 'UTF8', | ||
require => [ | ||
Package["postgresql-8.4"], | ||
Postgresql::Sqlfile["/usr/share/postgresql/8.4/contrib/postgis-1.5/spatial_ref_sys.sql"], | ||
Postgresql::User["vagrant"], | ||
], | ||
} | ||
# The template_postgis database has two tables, and these seem to inherit the | ||
# owner from the template db ('postgres') rather that the specified owner, so | ||
# need to change the owner. | ||
postgresql::sqlexec {"alter test template table owners": | ||
sql => "ALTER TABLE geometry_columns OWNER TO vagrant;ALTER TABLE spatial_ref_sys OWNER TO vagrant", | ||
database => "template_postgis", | ||
unless => "/usr/bin/psql -At --command='\\dt geometry_columns' template_postgis | cut -d '|' -f 4 | grep '^vagrant$'", | ||
require => [ | ||
Postgresql::User["vagrant"], | ||
Postgresql::Sqlfile["/usr/share/postgresql/8.4/contrib/postgis-1.5/spatial_ref_sys.sql"], | ||
Postgresql::Db["template_postgis"], | ||
] | ||
} | ||
|
||
package {["sphinxsearch", "ruby", "rubygems", "libxml2-dev", "libxslt1-dev", | ||
"libpq-dev", "memcached", "imagemagick"]: | ||
ensure => present, | ||
require => Exec["aptitude_update"], | ||
} | ||
|
||
package {"bundler": | ||
provider => gem, | ||
require => Package["rubygems"], | ||
ensure => '1.1.rc.7' | ||
} | ||
exec {"bundle": | ||
command => "/var/lib/gems/1.8/bin/bundle", | ||
cwd => '/vagrant', | ||
require => [ | ||
Postgresql::Db["inaturalist_development"], | ||
Package["bundler"], | ||
Package["libxml2-dev"], | ||
Package["libxslt1-dev"], | ||
Package["libpq-dev"] | ||
], | ||
timeout => 0 | ||
#refreshonly => true, | ||
} | ||
|
||
exec {"inaturalist_setup": | ||
command => "/var/lib/gems/1.8/bin/bundle exec rake inaturalist:setup", | ||
cwd => '/vagrant', | ||
unless => '/usr/bin/test -f "/vagrant/config/config.yml"', | ||
require => Exec["bundle"], | ||
} | ||
|
||
exec {"db_setup": | ||
command => "/var/lib/gems/1.8/bin/bundle exec rake db:setup", | ||
cwd => '/vagrant', | ||
require => [Postgresql::Db["inaturalist_development"], Exec["bundle"]], | ||
} | ||
|
||
exec {'gem_path': | ||
command => '/bin/echo \'PATH="/var/lib/gems/1.8/bin/:$PATH"\' >> /home/vagrant/.bashrc', | ||
cwd => '/home/vagrant/', | ||
unless => "/bin/grep 'var/lib/gems' /home/vagrant/.bashrc" | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class apt { | ||
|
||
package { "aptitude": | ||
ensure => present | ||
} | ||
|
||
exec { "aptitude_update": | ||
command => '/usr/bin/aptitude update', | ||
refreshonly => true, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
define apt::primary_mirror($country_code = $name, $ensure = 'present') { | ||
apt::source {"apt-primary_mirror-$name": | ||
source => "deb http://ftp.$country_code.debian.org/debian squeeze main non-free contrib", | ||
ensure => $ensure, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
define apt::source ($source, $ensure = present) { | ||
|
||
file { "/etc/apt/sources.list.d/$name.list": | ||
content => $source, | ||
ensure => $ensure, | ||
before => Exec["aptitude_update"], | ||
notify => Exec["aptitude_update"], | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
define postgresql::db ($owner = $user, $template = 'template0', | ||
$is_template = false, $encoding = 'SQL_ASCII', | ||
$user = 'postgres') { | ||
|
||
exec {"postgresql-createdb-$name": | ||
command => "/usr/bin/createdb -O $owner -E $encoding -T $template $name", | ||
user => $user, | ||
unless => "/usr/bin/psql -ltA | /bin/grep -q ^$name", | ||
} | ||
|
||
if $is_template { | ||
postgresql::sqlexec {"UPDATE pg_database SET datistemplate = TRUE WHERE datname = '$name'": | ||
require => Exec["postgresql-createdb-$name"], | ||
unless => "/usr/bin/psql -tA --command \"SELECT datname FROM pg_database WHERE datname = '$name' AND datistemplate = TRUE\" | /bin/grep -q ^$name", | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class postgresql { | ||
|
||
package { "postgresql-8.4": | ||
provider => aptitude, | ||
require => Exec["aptitude_update"], | ||
ensure => present, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
define postgresql::language($database, $language = $name) { | ||
postgresql::sqlexec { "postgresql-create_language-$name-$database": | ||
database => $database, | ||
sql => "CREATE LANGUAGE '$language'", | ||
unless => "/usr/bin/psql -tA -d $database --command \"SELECT lanname FROM pg_catalog.pg_language WHERE lanname = '$language'\" | grep -q ^$language", | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
define postgresql::sqlexec ($user = 'postgres', $unless = "/bin/false", $database = '', $sql = $name) { | ||
exec {"/usr/bin/psql --command \"$sql\" $database": | ||
user => $user, | ||
unless => $unless | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
define postgresql::sqlfile ($database, $user = 'postgres', | ||
$unless = "/bin/false") { | ||
exec {"/usr/bin/psql -f $name -d $database": | ||
user => $user, | ||
unless => $unless, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
define postgresql::user($password, $superuser = false, $createdb = false, | ||
$createrole = false, $login = true, $inherit = true) { | ||
$superuser_sql = $superuser ? { | ||
true => 'SUPERUSER', | ||
false => 'NOSUPERUSER', | ||
} | ||
$createdb_sql = $createdb ? { | ||
true => 'CREATEDB', | ||
false => 'NOCREATEDB', | ||
} | ||
$createrole_sql = $createrole ? { | ||
true => 'CREATEROLE', | ||
false => 'NOCREATEROLE', | ||
} | ||
$login_sql = $login ? { | ||
true => 'LOGIN', | ||
false => 'NOLOGIN', | ||
} | ||
$inherit_sql = $inherit ? { | ||
true => 'INHERIT', | ||
false => 'NOINHERIT', | ||
} | ||
postgresql::sqlexec {"CREATE USER $name PASSWORD '$password' $superuser_sql $createdb_sql $createrole_sql $login_sql $inherit_sql": | ||
unless => "/usr/bin/psql -tA --command '\\du $name' | /bin/grep -q ^$name", | ||
} | ||
} |