diff --git a/config/install.rb b/config/install.rb index 0a9b722..b87213a 100644 --- a/config/install.rb +++ b/config/install.rb @@ -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 @@ -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 diff --git a/config/stack/apache.rb b/config/stack/apache.rb index d133453..9094f54 100644 --- a/config/stack/apache.rb +++ b/config/stack/apache.rb @@ -5,6 +5,7 @@ end verify do + has_apt 'apache2' has_executable '/usr/sbin/apache2' end @@ -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 diff --git a/config/stack/essential.rb b/config/stack/essential.rb index 104c081..e36e96c 100644 --- a/config/stack/essential.rb +++ b/config/stack/essential.rb @@ -3,4 +3,8 @@ apt 'build-essential' do pre :install, 'apt-get update' end + + verify do + has_apt 'build-essential' + end end diff --git a/config/stack/gems/about_gem_packages.md b/config/stack/gems/about_gem_packages.md new file mode 100644 index 0000000..7fb1d57 --- /dev/null +++ b/config/stack/gems/about_gem_packages.md @@ -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. \ No newline at end of file diff --git a/config/stack/gems/bundler_gem.rb b/config/stack/gems/bundler_gem.rb new file mode 100644 index 0000000..17e2e7a --- /dev/null +++ b/config/stack/gems/bundler_gem.rb @@ -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 \ No newline at end of file diff --git a/config/stack/gems/curb_gem.rb b/config/stack/gems/curb_gem.rb new file mode 100644 index 0000000..787bb01 --- /dev/null +++ b/config/stack/gems/curb_gem.rb @@ -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 \ No newline at end of file diff --git a/config/stack/gems/mysql2_gem.rb b/config/stack/gems/mysql2_gem.rb new file mode 100644 index 0000000..8ef6224 --- /dev/null +++ b/config/stack/gems/mysql2_gem.rb @@ -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 diff --git a/config/stack/gems/mysql_gem.rb b/config/stack/gems/mysql_gem.rb new file mode 100644 index 0000000..63d068e --- /dev/null +++ b/config/stack/gems/mysql_gem.rb @@ -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 diff --git a/config/stack/gems/nokogiri_gem.rb b/config/stack/gems/nokogiri_gem.rb new file mode 100644 index 0000000..ec9c55e --- /dev/null +++ b/config/stack/gems/nokogiri_gem.rb @@ -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 \ No newline at end of file diff --git a/config/stack/gems/rmagick_gem.rb b/config/stack/gems/rmagick_gem.rb new file mode 100644 index 0000000..8e9a83c --- /dev/null +++ b/config/stack/gems/rmagick_gem.rb @@ -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 \ No newline at end of file diff --git a/config/stack/git.rb b/config/stack/git.rb new file mode 100644 index 0000000..2db70e0 --- /dev/null +++ b/config/stack/git.rb @@ -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 diff --git a/config/stack/git/github_key.txt b/config/stack/git/github_key.txt new file mode 100644 index 0000000..de142d2 --- /dev/null +++ b/config/stack/git/github_key.txt @@ -0,0 +1 @@ +github.com,207.97.227.239 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ== diff --git a/config/stack/mysql.rb b/config/stack/mysql.rb index bb509c1..3b4e5cf 100644 --- a/config/stack/mysql.rb +++ b/config/stack/mysql.rb @@ -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 diff --git a/config/stack/nginx.rb b/config/stack/nginx.rb index f9ca4c8..2e8ddd5 100644 --- a/config/stack/nginx.rb +++ b/config/stack/nginx.rb @@ -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 \ No newline at end of file diff --git a/config/stack/postfix.rb b/config/stack/postfix.rb new file mode 100644 index 0000000..b006193 --- /dev/null +++ b/config/stack/postfix.rb @@ -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 \ No newline at end of file diff --git a/config/stack/postgresql.rb b/config/stack/postgresql.rb index 343c462..1440387 100644 --- a/config/stack/postgresql.rb +++ b/config/stack/postgresql.rb @@ -17,5 +17,5 @@ has_gem 'postgres' end - requires :ruby_enterprise + requires :ruby end diff --git a/config/stack/ruby_enterprise.rb b/config/stack/ruby_enterprise.rb index f6b638e..688a0ae 100644 --- a/config/stack/ruby_enterprise.rb +++ b/config/stack/ruby_enterprise.rb @@ -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 \ No newline at end of file diff --git a/config/stack/ruby_enterprise/sslv2_patch b/config/stack/ruby_enterprise/sslv2_patch new file mode 100644 index 0000000..7b14e40 --- /dev/null +++ b/config/stack/ruby_enterprise/sslv2_patch @@ -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), diff --git a/config/stack/scm.rb b/config/stack/scm.rb deleted file mode 100644 index b6631e6..0000000 --- a/config/stack/scm.rb +++ /dev/null @@ -1,15 +0,0 @@ -package :git, :provides => :scm do - description 'Git Distributed Version Control' - version '1.6.1' - source "http://kernel.org/pub/software/scm/git/git-#{version}.tar.gz" - requires :git_dependencies - - 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