Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

new build with rvm supporting ruby 1.8.7 and 1.9.2

  • Loading branch information...
commit 13c1442fb53c148b1600891e86dcc7f891218460 1 parent 581dd86
@seamusabshere seamusabshere authored
View
6 Vagrantfile
@@ -5,12 +5,14 @@ Vagrant::Config.run do |config|
config.vm.customize do |vm|
vm.memory_size = 512
end
- config.chef.json[:network] = (ENV['NETWORK'] != 'false')
+ config.chef.json[:hagar_net] = ENV['NET']
config.chef.json[:hagar_apps] = Dir[File.join(hagar_root, 'apps_enabled', '*')].map { |name| File.basename(name) }
config.chef.json[:hagar_gems] = Dir[File.join(hagar_root, 'gems_enabled', '*')].map { |name| File.basename(name) }
- config.chef.json[:recipes] = ['vagrant_main']
+ # config.chef.json[:recipes] = ['vagrant_main']
config.vm.provisioner = :chef_solo
config.chef.cookbooks_path = "vagrant/chef-repo/cookbooks"
+ config.chef.run_list.clear
+ config.chef.add_recipe "vagrant_main"
config.vm.forward_port "ssh", 22, 2222
config.vm.forward_port "web", 80, 4567
config.vm.forward_port "web2", 8080, 5678
View
8 vagrant/chef-repo/cookbooks/mysql/templates/default/grants.sql.erb
@@ -1,6 +1,11 @@
# Generated by Chef for <%= node[:fqdn] %>.
# Local modifications will be overwritten.
+# sabshere 9/28/10
+# Set the server root password. This should be preseeded by the package installation.
+UPDATE mysql.user SET password = PASSWORD('password');
+FLUSH PRIVILEGES;
+
<% case node[:platform] -%>
<% when "debian","ubuntu" -%>
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY '<%= node[:mysql][:server_debian_password] %>' WITH GRANT OPTION;
@@ -9,4 +14,5 @@ GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, F
GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%' identified by '<%= node[:mysql][:server_repl_password] %>';
# Set the server root password. This should be preseeded by the package installation.
-SET PASSWORD FOR 'root'@'localhost' = PASSWORD('<%= node[:mysql][:server_root_password] %>');
+# sabshere 9/28/10 DISABLED ... look up
+# SET PASSWORD FOR 'root'@'localhost' = PASSWORD('<%= node[:mysql][:server_root_password] %>');
View
48 vagrant/chef-repo/cookbooks/tomcat6/attributes/default.rb
@@ -42,7 +42,53 @@
set_unless[:tomcat6][:version] = "6.0.18"
set_unless[:tomcat6][:with_native] = false
-set_unless[:tomcat6][:with_snmp] = !languages[:java][:runtime][:name].match(/^OpenJDK/)
+# sabshere 9/28/10
+# vagrant@vagrantup:~$ cd /tmp/vagrant-chef && sudo -E chef-solo -c solo.rb -j dna.json
+# [Tue, 28 Sep 2010 09:11:33 -0700] INFO: Setting the run_list to [] from JSON
+# [Tue, 28 Sep 2010 09:11:33 -0700] INFO: Starting Chef Run (Version 0.9.8)
+# [Tue, 28 Sep 2010 09:11:37 -0700] WARN: Missing gem 'mysql'
+# [Tue, 28 Sep 2010 09:11:37 -0700] WARN: Missing gem 'right_aws'
+# [Tue, 28 Sep 2010 09:11:37 -0700] ERROR: Running exception handlers
+# [Tue, 28 Sep 2010 09:11:37 -0700] ERROR: Exception handlers complete
+# [Tue, 28 Sep 2010 09:11:37 -0700] ERROR: Re-raising exception: NoMethodError - undefined method `[]' for nil:NilClass
+# /tmp/vagrant-chef/cookbooks-0/tomcat6/attributes/default.rb:45:in `from_file'
+# /usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/node.rb:531:in `load_attributes'
+# /usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/node.rb:529:in `each'
+# /usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/node.rb:529:in `load_attributes'
+# /usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/node.rb:528:in `each'
+# /usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/node.rb:528:in `load_attributes'
+# /usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/run_context.rb:74:in `load'
+# /usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/run_context.rb:55:in `initialize'
+# /usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/client.rb:84:in `new'
+# /usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/client.rb:84:in `run'
+# /usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/application/solo.rb:191:in `run_application'
+# /usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/application/solo.rb:181:in `loop'
+# /usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/application/solo.rb:181:in `run_application'
+# /usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/application.rb:62:in `run'
+# /usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/chef-solo:25
+# /usr/bin/chef-solo:19:in `load'
+# /usr/bin/chef-solo:19
+# /tmp/vagrant-chef/cookbooks-0/tomcat6/attributes/default.rb:45:in `from_file': undefined method `[]' for nil:NilClass (NoMethodError)
+# from /usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/node.rb:531:in `load_attributes'
+# from /usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/node.rb:529:in `each'
+# from /usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/node.rb:529:in `load_attributes'
+# from /usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/node.rb:528:in `each'
+# from /usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/node.rb:528:in `load_attributes'
+# from /usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/run_context.rb:74:in `load'
+# from /usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/run_context.rb:55:in `initialize'
+# from /usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/client.rb:84:in `new'
+# from /usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/client.rb:84:in `run'
+# from /usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/application/solo.rb:191:in `run_application'
+# from /usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/application/solo.rb:181:in `loop'
+# from /usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/application/solo.rb:181:in `run_application'
+# from /usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/application.rb:62:in `run'
+# from /usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/chef-solo:25
+# from /usr/bin/chef-solo:19:in `load'
+# from /usr/bin/chef-solo:19
+begin
+ set_unless[:tomcat6][:with_snmp] = !languages[:java][:runtime][:name].match(/^OpenJDK/)
+rescue NoMethodError
+end
set_unless[:tomcat6][:java_home] = "/usr/lib/jvm/java"
# snmp_opts fail with OpenJDK - results in silent exit(1) from the jre
if tomcat6[:with_snmp]
View
5 vagrant/chef-repo/cookbooks/vagrant_main/attributes/default.rb
@@ -1,7 +1,6 @@
-set[:mysql][:sabshere_override_password] = 'password'
set[:mysql][:server_root_password] = 'password'
set[:mysql][:server_debian_password] = 'password'
set[:mysql][:bind_address] = '0.0.0.0'
set[:apache][:user] = 'vagrant'
-set[:passenger_enterprise][:version] = "2.2.11"
-set[:passenger][:version] = "2.2.11"
+# set[:passenger_enterprise][:version] = "2.2.11"
+# set[:passenger][:version] = "2.2.11"
View
30 vagrant/chef-repo/cookbooks/vagrant_main/files/default/gem.rb
@@ -0,0 +1,30 @@
+#!/usr/bin/ruby1.8
+#--
+# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
+# All rights reserved.
+# See LICENSE.txt for permissions.
+#++
+
+# sabshere 9/30/10 to break myself of the habit
+if ENV['SUDO_COMMAND'] =~ /^\/usr\/bin\/gem/
+ raise '[hagar1] If you want to sudo gem, first sudo su'
+end
+
+require 'rubygems'
+require 'rubygems/gem_runner'
+require 'rubygems/exceptions'
+
+required_version = Gem::Requirement.new ">= 1.8.6"
+
+unless required_version.satisfied_by? Gem.ruby_version then
+ abort "Expected Ruby Version #{required_version}, is #{Gem.ruby_version}"
+end
+
+args = ARGV.clone
+
+begin
+ Gem::GemRunner.new.run args
+rescue Gem::SystemExitException => e
+ exit e.exit_code
+end
+
View
49 vagrant/chef-repo/cookbooks/vagrant_main/files/default/rep.rb
@@ -1,49 +0,0 @@
-#!/usr/bin/env ruby
-
-require 'fileutils'
-require 'rubygems'
-require 'active_support'
-require 'active_support/version'
-%w{
- active_support/core_ext/object/blank
-}.each do |active_support_3_requirement|
- require active_support_3_requirement
-end if ActiveSupport::VERSION::MAJOR == 3
-
-class StringReplacer
- NEWLINE = "AijQA6tD1wkWqgvLzXD"
- START_MARKER = '# START StringReplacer %s -- DO NOT MODIFY'
- END_MARKER = "# END StringReplacer %s -- DO NOT MODIFY#{NEWLINE}"
-
- attr_accessor :path
- def initialize(path)
- @path = path
- end
-
- def replace!(replacement, id, after_line)
- id = 1 unless id.present?
- after_line = nil unless after_line.present?
- new_path = "#{path}.new"
- backup_path = "#{path}.bak"
- current_start_marker = START_MARKER % id.to_s
- current_end_marker = END_MARKER % id.to_s
- replacement_with_markers = current_start_marker + NEWLINE + replacement + NEWLINE + current_end_marker
- text = IO.read(path).gsub("\n", NEWLINE)
- if text.include? current_start_marker
- text.sub! /#{Regexp.escape current_start_marker}.*#{Regexp.escape current_end_marker}/, replacement_with_markers
- elsif after_line
- text.sub! /(#{Regexp.escape after_line}#{Regexp.escape NEWLINE})/, '\1' + replacement_with_markers
- else
- text << NEWLINE << replacement_with_markers
- end
- text.gsub! NEWLINE, "\n"
- File.open(new_path, 'w') { |f| f.write text }
- FileUtils.mv path, backup_path
- FileUtils.mv new_path, path
- end
-end
-
-target, replacement, id, after_line = ARGV
-
-s = StringReplacer.new(target)
-s.replace! replacement, id, after_line
View
2  vagrant/chef-repo/cookbooks/vagrant_main/files/ruby_version.rb
@@ -0,0 +1,2 @@
+#!/usr/bin/env ruby
+puts "#{RUBY_VERSION}p#{RUBY_PATCHLEVEL}"
View
413 vagrant/chef-repo/cookbooks/vagrant_main/recipes/default.rb
@@ -2,96 +2,92 @@
# Cookbook Name:: vagrant_main
# Recipe:: default
#
-# Copyright 2010, Example Com
-#
-# 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.
-#
+
+def network?
+ node[:hagar_net] != 'false'
+end
::APPS = node[:hagar_apps]
::GEMS = node[:hagar_gems]
::PASSENGER_MAX_INSTANCES_PER_APP = 2
-::RAILS_2_VERSION = '2.3.8'
-::RAILS_3_VERSION = '3.0.0.rc2'
-::PASSENGER_VERSION = '2.2.11'
+::RAILS_2_VERSION = '2.3.9'
+::RAILS_3_VERSION = '3.0.0'
+::PASSENGER_VERSION = '2.2.15'
::HOME = '/home/vagrant'
::SHARED_FOLDER = '/vagrant'
::UNIVERSE = 'vagrant'
::MYSQL_PASSWORD = 'password'
+::RVM_RUBY_VERSIONS = %w{ ruby-1.8.7-p174 ruby-1.9.2-p0 }
+::DEFAULT_RUBY_VERSION = 'ruby-1.8.7-p174'
# steal a trick from mysql::client... run the apt-get update immediately
-# a = execute 'update apt-get' do
-# user 'root'
-# command '/usr/bin/apt-get update'
-# action :nothing
-# end
-# a.run_action :run
-#
-# execute 'define /etc/universe' do
-# user 'root'
-# command "/bin/echo \"#{::UNIVERSE}\" > /etc/universe"
-# end
-#
-# remote_file "/usr/bin/rep.rb" do
-# source "rep.rb"
-# mode '755'
-# end
-#
-# remote_file "/usr/bin/hostsync" do
-# source "hostsync"
-# mode '755'
-# end
-#
-# package 'libevent-dev'
-# require_recipe "memcached" # old memcached
-#
-# package "mysql-server"
-# package "libmysqlclient-dev"
-#
-# execute "ensure mysql password is set" do
-# user 'root'
-# command "/usr/bin/mysql -u root -e \"UPDATE mysql.user SET password = PASSWORD('#{::MYSQL_PASSWORD}'); FLUSH PRIVILEGES\""
-# not_if "/usr/bin/mysql -u root -p#{::MYSQL_PASSWORD} -e \"FLUSH PRIVILEGES\""
-# end
-#
-# package "sqlite3"
-# package "libsqlite3-dev"
-#
-# ::APPS.each do |name|
-# %w{ test development production }.each do |flavor|
-# execute "make sure we have a #{name} #{flavor} database" do
-# user 'vagrant'
-# command "/usr/bin/mysql -u root -p#{::MYSQL_PASSWORD} -e 'CREATE DATABASE IF NOT EXISTS #{name}_#{flavor}'"
-# end
-# end
-# end
-#
-# package 'git-core' # for bundler when the source is git
-# package 'libcurl4-openssl-dev' # for curb
-# package 'libxml2-dev' # for libxml-ruby and nokogiri
-# package 'libxslt1-dev' # for nokogiri
-# package 'libonig-dev' # for onigurama
-# package 'imagemagick' # for paperclip
-# package 'libsasl2-dev' # for memcached
-# package 'curl' # for data_miner and remote_table
-# package 'unzip' # for remote_table
-# package 'libsaxonb-java' # for data1
-# package 'apache2' # apparently this wasn't installed by default
-# package 'apache2-prefork-dev' # for passenger
-# package 'libapr1-dev' # for passenger
-# package 'libaprutil1-dev' # for passenger
-#
-# gem_versions = Hash.new
-# gem_beneficiaries = Hash.new
+if network?
+ a = execute 'update apt-get' do
+ user 'root'
+ command '/usr/bin/apt-get update'
+ action :nothing
+ end
+ a.run_action :run
+end
+
+if network?
+ package 'vim' # for derek
+ package 'libreadline-dev' # for 1.9.2 irb ... http://rvm.beginrescueend.com/packages/readline/
+ package 'g++' # for building passenger
+ package 'libevent-dev'
+ require_recipe "memcached" # old memcached
+ package "mysql-server"
+ package "libmysqlclient-dev"
+ package "sqlite3"
+ package "libsqlite3-dev"
+ package 'git-core' # for bundler when the source is git
+ package 'libcurl4-openssl-dev' # for curb
+ package 'libxml2-dev' # for libxml-ruby and nokogiri
+ package 'libxslt1-dev' # for nokogiri
+ package 'libonig-dev' # for onigurama
+ package 'imagemagick' # for paperclip
+ package 'libsasl2-dev' # for memcached
+ package 'curl' # for data_miner and remote_table
+ package 'unzip' # for remote_table
+ # # package 'libsaxonb-java' # for data1
+ package 'apache2' # apparently this wasn't installed by default
+ package 'apache2-prefork-dev' # for passenger
+ package 'libapr1-dev' # for passenger
+ package 'libaprutil1-dev' # for passenger
+end
+
+execute 'tell memcached to listen on all interfaces' do
+ user 'root'
+ command 'sed --expression="s/^-l/#-l/" --in-place="" /etc/memcached.conf'
+end
+
+execute "ensure mysql password is set" do
+ user 'root'
+ command "/usr/bin/mysql -u root -e \"UPDATE mysql.user SET password = PASSWORD('#{::MYSQL_PASSWORD}'); FLUSH PRIVILEGES\""
+ not_if "/usr/bin/mysql -u root -p#{::MYSQL_PASSWORD} -e \"FLUSH PRIVILEGES\""
+end
+
+::APPS.each do |name|
+ %w{ test development production }.each do |flavor|
+ execute "make sure we have a #{name} #{flavor} database" do
+ user 'vagrant'
+ command "/usr/bin/mysql -u root -p#{::MYSQL_PASSWORD} -e 'CREATE DATABASE IF NOT EXISTS #{name}_#{flavor}'"
+ end
+ end
+end
+
+execute 'define /etc/universe' do
+ user 'root'
+ command "/bin/echo \"#{::UNIVERSE}\" > /etc/universe"
+end
+
+cookbook_file "/usr/bin/hostsync" do
+ source "hostsync"
+ mode '755'
+end
+
+# sabshere 9/30/10 TODO for app1
+# gem install for apps that don't yet have Gemfiles
# ::APPS.each do |name|
# proto_rails_root = File.join ::SHARED_FOLDER, 'apps_enabled', name
# next if File.readable?(File.join(proto_rails_root, 'Gemfile'))
@@ -109,53 +105,133 @@
# gem_beneficiaries[gem_name] << name
# end
# end
-#
-# #common gems
-# execute 'install bundler' do
-# user 'root'
-# command 'gem install bundler --pre --no-rdoc --no-ri'
-# end
-#
-# gem_versions['passenger'] = [::PASSENGER_VERSION]
-# gem_versions['mysql'] = ['2.8.1']
-# gem_versions['sqlite3-ruby'] = ['1.2.5']
-# gem_versions['rails'] = [::RAILS_2_VERSION]
-# gem_versions['rails'] = ['2.3.5']
-# gem_versions['ruby-debug'] = ['0.10.3']
-# gem_versions['jeweler'] = ['1.4.0']
-# gem_versions['shoulda'] = ['2.10.3']
-# gem_versions['mocha'] = ['0.9.8']
-# gem_versions['taps'] = ['>=0.3.5']
-#
-# gem_versions.each do |name, versions|
-# versions.uniq.each do |x|
-# execute "install gem #{name} version #{x} on behalf of #{gem_beneficiaries[name].to_a.join(',')}" do
-# user 'root'
-# command "gem install #{name} --source=http://rubygems.org --source=http://gems.github.com#{" --version \"#{x}\"" unless x == 'latest'}"
-# not_if "gem list --installed #{name}#{" --version \"#{x}\"" unless x == 'latest'}"
-# end
-#
-# if x == 'latest'
-# execute "checking latest version of #{name} on behalf of #{gem_beneficiaries[name].to_a.join(',')}" do
-# user 'root'
-# command "gem update #{name}"
-# end
-# end
-# end
-# end
-#
-# execute 'install rails 3' do
-# user 'root'
-# command 'gem install rails --pre --no-rdoc --no-ri'
-# not_if "gem list --installed rails --version #{::RAILS_3_VERSION}"
-# end
-#
-# execute 'install passenger module for apache2' do
-# user 'root'
-# cwd "/usr/lib/ruby/gems/1.8/gems/passenger-#{::PASSENGER_VERSION}"
-# command 'rake apache2'
-# not_if "[ -f /usr/lib/ruby/gems/1.8/gems/passenger-#{::PASSENGER_VERSION}/ext/apache2/mod_passenger.so ]"
-# end
+
+if network?
+ gem_versions = Hash.new
+ gem_versions['rvm'] = ['latest']
+ gem_versions['string_replacer'] = ['latest']
+ gem_versions.each do |name, versions|
+ versions.uniq.each do |x|
+ execute "install gem #{name} version #{x}" do
+ user 'root'
+ command "gem install #{name} #{" --version \"#{x}\"" unless x == 'latest'}"
+ not_if "gem list --installed #{name}#{" --version \"#{x}\"" unless x == 'latest'}"
+ end
+
+ if x == 'latest'
+ execute "checking latest version of #{name}" do
+ user 'root'
+ command "gem update #{name}"
+ end
+ end
+ end
+ end
+end
+
+if network?
+ remote_file "/usr/bin/rvm-install-system-wide" do
+ owner 'root'
+ source "http://bit.ly/rvm-install-system-wide"
+ mode '755'
+ end
+
+ execute 'install rvm system-wide' do
+ user 'root'
+ command 'rvm-install-system-wide'
+ ignore_failure true
+ not_if "grep rvm /etc/group"
+ end
+
+ ::RVM_RUBY_VERSIONS.each do |v|
+ execute "install #{v}" do
+ user 'root'
+ command "rvm install #{v}" # -C --with-readline-dir=/usr
+ not_if "rvm list | grep #{v}"
+ end
+ end
+end
+
+execute 'add vagrant to rvm group' do
+ user 'root'
+ command 'usermod --append --groups rvm vagrant'
+ ignore_failure true
+end
+
+execute "set #{::DEFAULT_RUBY_VERSION} as the default ruby" do
+ user 'root'
+ command "rvm --default #{::DEFAULT_RUBY_VERSION}"
+ ignore_failure true
+end
+
+cookbook_file '/usr/bin/ruby_version.rb' do
+ owner 'root'
+ source 'ruby_version.rb'
+ mode '755'
+end
+
+cookbook_file '/usr/bin/gem' do
+ owner 'root'
+ source 'gem.rb'
+ mode '755'
+end
+
+{
+ 'vagrant' => '/home/vagrant',
+ 'root' => '/root'
+}.each do |username, homedir|
+ execute "set up rvm as a bash function for the #{username} user" do
+ user username
+ command "string_replacer #{homedir}/.bashrc \"[[ -s \\\"/usr/local/lib/rvm\\\" ]] && . \\\"/usr/local/lib/rvm\\\"\" \"set up rvm as a bash function\""
+ end
+ execute "show current ruby version on the vagrant prompt for #{username}" do
+ user username
+ command "string_replacer #{homedir}/.bashrc \"PS1=\\\"\\\\\\\\\\\`/usr/bin/ruby_version.rb\\\\\\\\\\\` \\\$PS1\\\"\" \"current ruby version\""
+ end
+end
+
+gem_installs = Hash.new
+gem_installs['ruby-debug'] = [/1.8.7/, 'latest']
+gem_installs['fastercsv'] = [/1.8.7/, 'latest'] # long story
+gem_installs['bundler'] = ['all', 'latest']
+gem_installs['passenger'] = ['all', ::PASSENGER_VERSION]
+gem_installs['unicorn'] = ['all', 'latest']
+gem_installs['mysql'] = ['all', 'latest']
+gem_installs['sqlite3-ruby'] = ['all', 'latest']
+gem_installs['rails'] = ['all', ::RAILS_3_VERSION]
+gem_installs['jeweler'] = ['all', 'latest']
+gem_installs['shoulda'] = ['all', 'latest']
+gem_installs['mocha'] = ['all', 'latest']
+gem_installs['taps'] = ['all', 'latest']
+
+if network?
+ ::RVM_RUBY_VERSIONS.each do |v|
+ gem_installs.each do |name, into|
+ ruby_version, gem_version = into
+ if ruby_version == 'all' or ruby_version =~ v
+ execute "install gem #{name} version #{gem_version} in ruby version #{v}" do
+ user 'vagrant'
+ command "rvm #{v} gem install #{name} --no-rdoc --no-ri #{" --version \"#{gem_version}\"" unless gem_version == 'latest'}"
+ not_if "rvm #{v} gem list --installed #{name}#{" --version \"#{gem_version}\"" unless gem_version == 'latest'}"
+ end
+ if gem_version == 'latest'
+ execute "checking latest version of #{name} in ruby version #{v}" do
+ user 'vagrant'
+ command "rvm #{v} gem update #{name} --no-rdoc --no-ri"
+ end
+ end
+ end
+ end
+ end
+end
+
+::RVM_RUBY_VERSIONS.each do |ruby_version|
+ execute "prepare passenger module for apache2 in #{ruby_version}" do
+ user 'vagrant'
+ cwd "/usr/local/rvm/gems/#{ruby_version}/gems/passenger-#{::PASSENGER_VERSION}"
+ command "rvmsudo #{ruby_version} rake apache2"
+ not_if "[ -f /usr/local/rvm/gems/#{ruby_version}/gems/passenger-#{::PASSENGER_VERSION}/ext/apache2/mod_passenger.so ]"
+ end
+end
template "/etc/apache2/mods-available/passenger.conf" do
cookbook "vagrant_main"
@@ -164,8 +240,10 @@
group "root"
mode 0644
variables(
- :passenger_max_instances_per_app => ::PASSENGER_MAX_INSTANCES_PER_APP,
- :passenger_version => ::PASSENGER_VERSION
+ :passenger_version => ::PASSENGER_VERSION,
+ :rubies => ::RVM_RUBY_VERSIONS,
+ :default_ruby_version => ::DEFAULT_RUBY_VERSION,
+ :passenger_max_instances_per_app => ::PASSENGER_MAX_INSTANCES_PER_APP
)
end
@@ -175,7 +253,11 @@
owner "root"
group "root"
mode 0644
- variables :passenger_version => ::PASSENGER_VERSION
+ variables(
+ :passenger_version => ::PASSENGER_VERSION,
+ :rubies => ::RVM_RUBY_VERSIONS,
+ :default_ruby_version => ::DEFAULT_RUBY_VERSION
+ )
end
execute "enable passenger.load" do
@@ -184,18 +266,9 @@
unlink /etc/apache2/mods-enabled/passenger.load;
ln -s /etc/apache2/mods-available/passenger.load /etc/apache2/mods-enabled/passenger.load;
unlink /etc/apache2/mods-enabled/passenger.conf;
- ln -s /etc/apache2/mods-available/passenger.conf /etc/apache2/mods-enabled/passenger.conf;
- /bin/true
+ ln -s /etc/apache2/mods-available/passenger.conf /etc/apache2/mods-enabled/passenger.conf
}
-end
-
-# note: currently ignoring dot-files
-::IGNORED_PATHS = %w{ .bundle .git .vagrant vagrant Vagrantfile vagrant_main }
-
-execute "clear out old enabled sites" do
- user 'root'
- command "/usr/bin/find /etc/apache2/sites-enabled -maxdepth 1 -type l | /usr/bin/xargs -n 1 /usr/bin/unlink; /bin/true"
- # note that I am ignoring errors with /bin/true
+ ignore_failure true
end
::GEMS.each do |name|
@@ -204,8 +277,8 @@
execute "clear the way for #{gem_root}" do
user 'vagrant'
- command "unlink #{gem_root}; rm -rf #{gem_root}; /bin/true"
- # ignoring failure
+ command "unlink #{gem_root}; rm -rf #{gem_root}"
+ ignore_failure true
end
execute "symbolic link #{proto_gem_root} from read-only shared dir" do
@@ -214,9 +287,19 @@
end
end
+execute "clear out old enabled sites" do
+ user 'root'
+ command "/usr/bin/find /etc/apache2/sites-enabled -maxdepth 1 -type l | /usr/bin/xargs -n 1 /usr/bin/unlink"
+ ignore_failure true
+end
+
+# note: currently ignoring dot-files
+::IGNORED_PATHS = %w{ .bundle .git }
+
::APPS.each do |name|
proto_rails_root = File.join ::SHARED_FOLDER, 'apps_enabled', name
rails_root = File.join ::HOME, name
+ ruby_version = File.exist?(File.join(rails_root, 'RUBY_VERSION')) ? IO.read(File.join(rails_root, 'RUBY_VERSION')).chomp : ::DEFAULT_RUBY_VERSION
execute "create #{rails_root}" do
user 'vagrant'
@@ -225,14 +308,14 @@
execute "clear out old symlinks from #{rails_root}" do
user 'vagrant'
- command "/usr/bin/find #{rails_root} -maxdepth 1 -type l | /usr/bin/xargs -n 1 /usr/bin/unlink; /bin/true"
- # note that I am ignoring errors with /bin/true
+ command "/usr/bin/find #{rails_root} -maxdepth 1 -type l | /usr/bin/xargs -n 1 /usr/bin/unlink"
+ ignore_failure true
end
execute "clear out tmp and log from #{rails_root}" do
user 'root'
- command "mkdir -p #{rails_root}/tmp; mkdir -p #{rails_root}/log; rm -rf #{rails_root}/tmp/* #{rails_root}/log/*; chown vagrant #{rails_root}/log; chown vagrant #{rails_root}/tmp; /bin/true"
- #ignoring failure
+ command "mkdir -p #{rails_root}/tmp; mkdir -p #{rails_root}/log; rm -rf #{rails_root}/tmp/* #{rails_root}/log/*; chown vagrant #{rails_root}/log; chown vagrant #{rails_root}/tmp"
+ ignore_failure true
end
Dir[File.join(proto_rails_root, '*')].delete_if { |linkable_path| (::IGNORED_PATHS).include?(File.basename(linkable_path)) }.each do |linkable_path|
@@ -259,22 +342,25 @@
execute "enable site for #{name}" do
user 'root'
- command "/bin/ln -s /etc/apache2/sites-available/#{name}.conf /etc/apache2/sites-enabled/#{name}.conf; /bin/true"
- # ignoring fail
+ command "/bin/ln -s /etc/apache2/sites-available/#{name}.conf /etc/apache2/sites-enabled/#{name}.conf"
+ ignore_failure true
end
- if File.readable?(File.join(rails_root, 'Gemfile'))
+ if File.exist?(File.join(rails_root, 'Gemfile'))
execute "make sure user can write to bundle for #{name}" do
user 'root'
- command "chown -R vagrant /home/vagrant/.bundle; chown -R vagrant #{rails_root}/.bundle; /bin/true"
- # ignoring fail
+ command "chown -R vagrant /home/vagrant/.bundle; chown -R vagrant #{rails_root}/.bundle"
+ ignore_failure true
end
- # execute "run bundler install for #{name}" do
- # user 'vagrant'
- # command 'bundle install'
- # cwd rails_root
- # end
+ if network?
+ execute "run bundler install for #{name}" do
+ user 'vagrant'
+ command "rvm #{ruby_version} exec bundle install"
+ cwd rails_root
+ ignore_failure true
+ end
+ end
end
end
@@ -285,6 +371,15 @@
end
end
+template "/home/vagrant/.bash_aliases" do
+ cookbook "vagrant_main"
+ source ".bash_aliases.erb"
+ owner "vagrant"
+ group "vagrant"
+ mode 0644
+ variables :repos => GEMS+APPS
+end
+
execute "make sure git autocrlf is set" do
user 'vagrant'
command 'git config --global core.autocrlf input'
@@ -292,12 +387,12 @@
execute 'make sure mysqld uses innodb' do
user 'root'
- command '/usr/bin/rep.rb /etc/mysql/my.cnf default-storage-engine=INNODB "make sure mysqld uses innodb" "[mysqld]"'
+ command 'string_replacer /etc/mysql/my.cnf default-storage-engine=INNODB "make sure mysqld uses innodb" "[mysqld]"'
end
execute 'make sure sendfile is off' do
user 'root'
- command '/usr/bin/rep.rb /etc/apache2/apache2.conf "EnableSendfile Off" "make sure sendfile is off" "HostnameLookups Off"'
+ command 'string_replacer /etc/apache2/apache2.conf "EnableSendfile Off" "make sure sendfile is off" "HostnameLookups Off"'
end
execute "restart apache" do
View
6 vagrant/chef-repo/cookbooks/vagrant_main/templates/default/.bash_aliases.erb
@@ -0,0 +1,6 @@
+<% @repos.each do |repo| %>
+if [ ! `which <%= repo %>` ]
+then
+ alias <%= repo %>="cd ~/<%= repo %>"
+fi
+<% end %>
View
6 vagrant/chef-repo/cookbooks/vagrant_main/templates/default/passenger.conf.erb
@@ -1,6 +1,8 @@
<IfModule mod_passenger.c>
- PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-<%= @passenger_version %>
- PassengerRuby /usr/bin/ruby1.8
+ <% @rubies.each do |ruby_version| -%>
+ <% unless ruby_version == @default_ruby_version %>#<% end %>PassengerRoot /usr/local/rvm/gems/<%= ruby_version %>/gems/passenger-<%= @passenger_version %>
+ <% unless ruby_version == @default_ruby_version %>#<% end %>PassengerRuby /usr/local/rvm/wrappers/<%= ruby_version %>/ruby
+ <% end -%>
PassengerMaxPoolSize 6
PassengerMaxInstancesPerApp <%= @passenger_max_instances_per_app %>
</IfModule>
View
5 vagrant/chef-repo/cookbooks/vagrant_main/templates/default/passenger.load.erb
@@ -1 +1,4 @@
-LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-<%= @passenger_version %>/ext/apache2/mod_passenger.so
+<% @rubies.each do |ruby_version| -%>
+<% unless ruby_version == @default_ruby_version %>#<% end %>LoadModule passenger_module /usr/local/rvm/gems/<%= ruby_version %>/gems/passenger-<%= @passenger_version %>/ext/apache2/mod_passenger.so
+<% end -%>
+
Please sign in to comment.
Something went wrong with that request. Please try again.