Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
2bf8534
Improve idempotency by allowing ln to run if recipe is executed a sec…
sbleon Dec 22, 2011
f74b4b8
Switch to a version of git that doesn't 404.
sbleon Dec 22, 2011
5a2aaa6
Add compilation dependency for apache2 module.
sbleon Dec 22, 2011
0f281a6
Backup and recreate passenger.conf
sbleon Dec 22, 2011
772e88b
Changed path of validated location of apache2 module to match where i…
sbleon Dec 22, 2011
92588ea
Fix the way I replace passenger.conf
sbleon Dec 22, 2011
e75a8ab
Updated passenger version to one that currently gets downloaded. This…
sbleon Dec 22, 2011
81e51af
Sorry for the big commit! This includes many things:
sbleon Dec 23, 2011
37937d5
Comment pre-install SSLv2 patch.
sbleon Dec 26, 2011
e0fd59c
Switched from using "ruby_enterprise" as a dependency in favor of jus…
sbleon Dec 26, 2011
ae7c44d
Switch to generic 'ruby' metapackage name instead of specifying ruby_…
sbleon Dec 26, 2011
7879c53
Whoops! Shouldn't have changed that one "ruby_enterprise" in the requ…
sbleon Dec 26, 2011
9be58ff
Clean up dependencies, avoiding double "installing" message.
sbleon Dec 26, 2011
74f585f
Rename "scm" file to "git" so it's clear what it is.
sbleon Dec 26, 2011
706586e
Add github ssh keys for all users on system
sbleon Dec 26, 2011
dfeb635
Added some gems
sbleon Dec 27, 2011
1484587
Moved Mysql gem into its own package and file so it can be installed …
sbleon Dec 27, 2011
10c667b
Added mysql2 gem
sbleon Dec 28, 2011
7c0ddad
Added some missing verifiers. Standardized on gnutls SSL packages (in…
sbleon Dec 29, 2011
79e3185
Added postfix mail server
sbleon Jan 3, 2012
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions config/install.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
$:<< File.join(File.dirname(__FILE__), 'stack')

# Require the stack base
%w(essential scm ruby_enterprise memcached postgresql mysql).each do |lib|
%w(essential git ruby_enterprise memcached postgresql mysql).each do |lib|
require lib
end

Expand All @@ -24,7 +24,7 @@
policy :stack, :roles => :app do
requires :webserver # Apache or Nginx
requires :appserver # Passenger
requires :ruby_enterprise # Ruby Enterprise edition
requires :ruby # Ruby Enterprise edition
requires :database # MySQL or Postgres, also installs rubygems for each
requires :scm # Git
#requires :memcached # Memcached
Expand Down
52 changes: 39 additions & 13 deletions config/stack/apache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
end

verify do
has_apt 'apache2'
has_executable '/usr/sbin/apache2'
end

Expand All @@ -15,41 +16,66 @@
package :apache2_prefork_dev do
description 'A dependency required by some packages.'
apt 'apache2-prefork-dev'

verify do
has_apt 'apache2-prefork-dev'
end
end

package :passenger, :provides => :appserver do
description 'Phusion Passenger (mod_rails)'
version '2.2.4'
version '3.0.11' # I don't think this version is necessarily installed, as I had to update this the version of passenger it had gotten me.
binaries = %w(passenger-config passenger-install-nginx-module passenger-install-apache2-module passenger-make-enterprisey passenger-memory-stats passenger-spawn-server passenger-status passenger-stress-test)


passenger_config = '/etc/apache2/extras/passenger.conf'
passenger_gem_path = "#{RUBY_PATH}/lib/ruby/gems/1.8/gems/passenger-#{version}"
passenger_module = "#{passenger_gem_path}/ext/apache2/mod_passenger.so"

gem 'passenger', :version => version do
binaries.each {|bin| post :install, "ln -s #{REE_PATH}/bin/#{bin} /usr/local/bin/#{bin}"}
binaries.each {|bin| post :install, "ln -s -f #{RUBY_PATH}/bin/#{bin} /usr/local/bin/#{bin}"} # The -f forces the operation, so it doesn't fail the second time you run it.

post :install, 'echo -en "\n\n\n\n" | sudo passenger-install-apache2-module'

# Create the passenger conf file
# SET UP CONFIG FILE
# set up directory
post :install, 'mkdir -p /etc/apache2/extras'
post :install, 'touch /etc/apache2/extras/passenger.conf'
post :install, 'echo "Include /etc/apache2/extras/passenger.conf"|sudo tee -a /etc/apache2/apache2.conf'
# blast old file (I should back it up, but oh well)
post :install, "rm -rf #{passenger_config}"
# recreate file
post :install, "touch #{passenger_config}"

[%Q(LoadModule passenger_module /usr/local/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-#{version}/ext/apache2/mod_passenger.so),
%Q(PassengerRoot /usr/local/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-#{version}),
[%Q(LoadModule passenger_module #{passenger_module}),
%Q(PassengerRoot #{passenger_gem_path}),
%q(PassengerRuby /usr/local/bin/ruby),
%q(RailsEnv production)].each do |line|
post :install, "echo '#{line}' |sudo tee -a /etc/apache2/extras/passenger.conf"
post :install, "echo '#{line}' |sudo tee -a #{passenger_config}"
end

# Tell apache to use new config file
post :install, "echo 'Include #{passenger_config}'|sudo tee -a /etc/apache2/apache2.conf"
# Restart apache to note changes
post :install, '/etc/init.d/apache2 restart'
end

verify do
has_file "/etc/apache2/extras/passenger.conf"
has_file "#{REE_PATH}/ext/apache2/mod_passenger.so"
binaries.each {|bin| has_symlink "/usr/local/bin/#{bin}", "#{REE_PATH}/bin/#{bin}" }
has_gem 'passenger', version
has_file passenger_config
has_file passenger_module
binaries.each {|bin| has_symlink "/usr/local/bin/#{bin}", "#{RUBY_PATH}/bin/#{bin}" }
# This should work, but on Ubuntu Lucid Lynx (10.04), apache2 doesn't start automatically
# and needs to be started manually.
#has_process "apache2"
end

requires :apache, :apache2_prefork_dev, :ruby_enterprise
requires :apache, :apache2_prefork_dev, :ruby, :passenger_dependencies
end

package :passenger_dependencies do
apt 'libcurl4-gnutls-dev' # Compilation dependency for apache module

verify do
has_apt 'libcurl4-gnutls-dev'
end
end

# These "installers" are strictly optional, I believe
Expand Down
4 changes: 4 additions & 0 deletions config/stack/essential.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@
apt 'build-essential' do
pre :install, 'apt-get update'
end

verify do
has_apt 'build-essential'
end
end
13 changes: 13 additions & 0 deletions config/stack/gems/about_gem_packages.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Sprinkle packages for gems
--------------------------

**Why write packages for gems, which are themselves packages?**
Because they often have system-level dependencies, which the gemspec doesn't
document. This lets us document them and install their dependencies during
the initial stack install.

**Why do they have names like *_gem.rb?**
This differentiates them from the gem's own files. If you try to require
something like "bundler", you'll get a warning about it not
having a package definition for "bundler", because it's loaded the Bundler
class, not your package file.
12 changes: 12 additions & 0 deletions config/stack/gems/bundler_gem.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package :bundler_gem do
description "Bundler gem"
requires :ruby

gem 'bundler' do
post :install, "ln -s -f #{RUBY_PATH}/bin/bundle /usr/local/bin/bundle"
end

verify do
has_gem 'bundler'
end
end
22 changes: 22 additions & 0 deletions config/stack/gems/curb_gem.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package :curb_gem do
description "The curb gem, a curl interface in ruby"

requires :curb_dependencies

gem 'curb'

verify do
has_gem 'curb'
end
end

package :curb_dependencies do
requires :build_essential
apt %w(libcurl3 libcurl3-gnutls libcurl4-gnutls-dev)

verify do
has_apt 'libcurl3'
has_apt 'libcurl3-gnutls'
has_apt 'libcurl4-gnutls-dev'
end
end
12 changes: 12 additions & 0 deletions config/stack/gems/mysql2_gem.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package :mysql2_gem, :provides => :ruby_database_driver do
description 'Ruby MySQL2 gem'
apt 'libmysqlclient-dev'

gem 'mysql2'

verify do
has_gem 'mysql2'
end

requires :ruby
end
12 changes: 12 additions & 0 deletions config/stack/gems/mysql_gem.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package :mysql_gem, :provides => :ruby_database_driver do
description 'Ruby MySQL gem'
apt 'libmysqlclient-dev'

gem 'mysql'

verify do
has_gem 'mysql'
end

requires :ruby
end
16 changes: 16 additions & 0 deletions config/stack/gems/nokogiri_gem.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package :nokogiri_gem do
description "nokogiri gem (xml library)"

requires :nokogiri_dependencies, :ruby

gem 'nokogiri'

verify do
has_gem 'nokogiri'
end
end

package :nokogiri_dependencies do
requires :build_essential
apt %w(libxslt-dev libxml2-dev)
end
18 changes: 18 additions & 0 deletions config/stack/gems/rmagick_gem.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package :rmagick_gem do
description "The rmagick gem, an image manipulation library"

requires :rmagick_dependencies

gem 'rmagick'

verify do
has_gem 'rmagick'
end
end

package :rmagick_dependencies do
requires :build_essential
# TODO: This package requires 179MB of disk on my Ubuntu Oneiric server. A binary
# installation of RMagick would be really nice!
apt 'libmagick9-dev'
end
25 changes: 25 additions & 0 deletions config/stack/git.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package :git, :provides => :scm do
description 'Git Distributed Version Control'
version '1.7.7.5'
source "http://git-core.googlecode.com/files/git-#{version}.tar.gz"
requires :git_dependencies, :github_keys

verify do
has_file '/usr/local/bin/git'
end
end

package :git_dependencies do
description 'Git Build Dependencies'
apt 'git-core', :dependencies_only => true
end

package :github_keys do
github_key = File.read(File.join(File.dirname(__FILE__), 'git', 'github_key.txt'))
# Don't require verification of github's ssh fingerprint for anyone on the system
push_text github_key, '/etc/ssh/ssh_known_hosts', :sudo => true

verify do
file_contains '/etc/ssh/ssh_known_hosts', 'github.com'
end
end
1 change: 1 addition & 0 deletions config/stack/git/github_key.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github.com,207.97.227.239 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==
13 changes: 0 additions & 13 deletions config/stack/mysql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,4 @@
verify do
has_executable 'mysql'
end

optional :mysql_driver
end

package :mysql_driver, :provides => :ruby_database_driver do
description 'Ruby MySQL database driver'
gem 'mysql'

verify do
has_gem 'mysql'
end

requires :ruby_enterprise
end
6 changes: 3 additions & 3 deletions config/stack/nginx.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@

gem 'passenger', :version => version do
# Install nginx and the module
binaries.each {|bin| post :install, "ln -s #{REE_PATH}/bin/#{bin} /usr/local/bin/#{bin}"}
binaries.each {|bin| post :install, "ln -s #{RUBY_PATH}/bin/#{bin} /usr/local/bin/#{bin}"}
post :install, "sudo passenger-install-nginx-module --auto --auto-download --prefix=/usr/local/nginx"
end

requires :ruby_enterprise
requires :ruby, :nginx

verify do
has_gem "passenger", version
binaries.each {|bin| has_symlink "/usr/local/bin/#{bin}", "#{REE_PATH}/bin/#{bin}" }
binaries.each {|bin| has_symlink "/usr/local/bin/#{bin}", "#{RUBY_PATH}/bin/#{bin}" }
end
end
9 changes: 9 additions & 0 deletions config/stack/postfix.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package :postfix, :provides => :smtp do
description "Postfix SMTP server for outgoing mail"

apt 'postfix'

verify do
has_apt 'postfix'
end
end
2 changes: 1 addition & 1 deletion config/stack/postgresql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
has_gem 'postgres'
end

requires :ruby_enterprise
requires :ruby
end
30 changes: 21 additions & 9 deletions config/stack/ruby_enterprise.rb
Original file line number Diff line number Diff line change
@@ -1,24 +1,36 @@
package :ruby_enterprise do
package :ruby_enterprise, :provides => :ruby do
description 'Ruby Enterprise Edition'
version '1.8.7-2010.01'
REE_PATH = "/usr/local/ruby-enterprise"
version '1.8.7-2011.03'
ree_path = "/opt/ruby-enterprise-#{version}"
# Other packages may reference this
RUBY_PATH = ree_path

binaries = %w(erb gem irb rackup rails rake rdoc ree-version ri ruby testrb)
source "http://rubyforge.org/frs/download.php/68719/ruby-enterprise-#{version}.tar.gz" do
custom_install 'sudo ./installer --auto=/usr/local/ruby-enterprise'
binaries.each {|bin| post :install, "ln -s #{REE_PATH}/bin/#{bin} /usr/local/bin/#{bin}" }
# Apply patch to remove SSLv2 support, which is no longer present in Ubuntu 11.10 and OpenSSL >1.0
push_text File.read(File.join(File.dirname(__FILE__), 'ruby_enterprise', 'sslv2_patch')), "/tmp/sslv2_patch", :sudo => true
source "http://rubyenterpriseedition.googlecode.com/files/ruby-enterprise-#{version}.tar.gz" do
post :extract, "patch /usr/local/build/ruby-enterprise-1.8.7-2011.03/source/ext/openssl/ossl_ssl.c < /tmp/sslv2_patch"
custom_install "sudo ./installer --auto=#{ree_path} --dont-install-useful-gems --no-dev-docs"
binaries.each {|bin| post :install, "ln -s #{ree_path}/bin/#{bin} /usr/local/bin/#{bin}" }
end

verify do
has_directory install_path
has_executable "#{REE_PATH}/bin/ruby"
binaries.each {|bin| has_symlink "/usr/local/bin/#{bin}", "#{REE_PATH}/bin/#{bin}" }
has_executable "#{ree_path}/bin/ruby"
binaries.each {|bin| has_symlink "/usr/local/bin/#{bin}", "#{ree_path}/bin/#{bin}" }
end

requires :ree_dependencies
end

package :ree_dependencies do
apt %w(zlib1g-dev libreadline5-dev libssl-dev)
apt %w(zlib1g-dev libreadline-dev libssl-dev)
requires :build_essential

verify do
has_apt 'zlib1g-dev'
has_apt 'libreadline-dev'
has_apt 'libssl-dev'
has_apt 'curl'
end
end
8 changes: 8 additions & 0 deletions config/stack/ruby_enterprise/sslv2_patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
104,106c104,106
< OSSL_SSL_METHOD_ENTRY(SSLv2),
< OSSL_SSL_METHOD_ENTRY(SSLv2_server),
< OSSL_SSL_METHOD_ENTRY(SSLv2_client),
---
> // OSSL_SSL_METHOD_ENTRY(SSLv2),
> // OSSL_SSL_METHOD_ENTRY(SSLv2_server),
> // OSSL_SSL_METHOD_ENTRY(SSLv2_client),
15 changes: 0 additions & 15 deletions config/stack/scm.rb

This file was deleted.