sml-rubber 0.9.4 → 0.9.5

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.4
1
+ 0.9.5
data/bin/vulcanize ADDED
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ env = ENV['RUBBER_ENV'] || ENV['RAILS_ENV'] || 'development'
4
+ root = '.'
5
+ RAILS_ENV = ENV['RAILS_ENV'] = env
6
+ RAILS_ROOT = ENV['RAILS_ROOT'] = root
7
+
8
+ # need a minimal rails environment for generators to run
9
+ require 'rubygems'
10
+ gem 'rails'
11
+ module Rails
12
+ class << self
13
+ def vendor_rails?
14
+ false
15
+ end
16
+ end
17
+ end
18
+
19
+ require 'initializer'
20
+ class Rails::Initializer
21
+ def load_environment; end
22
+ end
23
+
24
+ Rails::Initializer.run do |config|
25
+ config.frameworks -= [:active_record, :action_controller]
26
+ end
27
+
28
+ require 'rails_generator'
29
+ require 'rails_generator/scripts/generate'
30
+
31
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
32
+ Rails::Generator::Scripts::Generate.new.run(['vulcanize'] + ARGV)
@@ -3,13 +3,57 @@ namespace :rubber do
3
3
 
4
4
  rubber.allow_optional_tasks(self)
5
5
 
6
+
7
+ before "rubber:install_packages", "rubber:base:pre_install_ruby"
8
+ task :pre_install_ruby do
9
+
10
+ # figure out which hosts we have specified enterprise ruby for
11
+ sys_ruby_hosts = []
12
+ ent_ruby_hosts = []
13
+ rubber_cfg.instance.filtered.each do |ic|
14
+ env = rubber_cfg.environment.bind(ic.role_names, ic.name)
15
+ if env.use_enterprise_ruby
16
+ ent_ruby_hosts << ic.full_name
17
+ end
18
+ end
19
+
20
+ if ent_ruby_hosts.size > 0
21
+
22
+ task :_install_enterprise_ruby, :hosts => ent_ruby_hosts do
23
+
24
+ # preferences to pick up specific Ruby packages from brightbox
25
+ prefs = <<-DATA
26
+ Package: *
27
+ Pin: release l=brightbox
28
+ Pin-Priority: 1001
29
+
30
+ Package: ruby1.8-elisp
31
+ Pin: release l=Ubuntu
32
+ Pin-Priority: 1001
33
+ DATA
34
+
35
+ prefs.gsub!(/^ */, '') # remove leading whitespace
36
+ put(prefs, '/etc/apt/preferences')
37
+
38
+ rubber.sudo_script 'install_enterprise_ruby', <<-ENDSCRIPT
39
+ wget http://apt.brightbox.net/release.asc -O - | apt-key add -
40
+ echo "deb http://apt.brightbox.net/ hardy rubyee" > /etc/apt/sources.list.d/brightbox-rubyee.list
41
+ ENDSCRIPT
42
+
43
+ end
44
+
45
+ _install_enterprise_ruby
46
+ end
47
+
48
+ end
49
+
6
50
  # The ubuntu rubygem package is woefully out of date, so install it manually
7
51
  after "rubber:install_packages", "rubber:base:install_rubygems"
8
52
  task :install_rubygems do
9
- ver = "1.3.1"
10
- src_url = "http://rubyforge.org/frs/download.php/45905/rubygems-#{ver}.tgz"
53
+ ver = "1.3.5"
54
+ src_url = "http://rubyforge.org/frs/download.php/60718/rubygems-#{ver}.tgz"
11
55
  rubber.sudo_script 'install_rubygems', <<-ENDSCRIPT
12
- if [ ! -f /usr/bin/gem ]; then
56
+ if [[ `gem --version 2>&1` != "#{ver}" ]]; then
13
57
  wget -qP /tmp #{src_url}
14
58
  tar -C /tmp -xzf /tmp/rubygems-#{ver}.tgz
15
59
  ruby -C /tmp/rubygems-#{ver} setup.rb
@@ -35,6 +79,12 @@ namespace :rubber do
35
79
  apt-get install liberror-perl libdigest-sha1-perl
36
80
  wget -qO /tmp/git.deb ${src}
37
81
  dpkg -i /tmp/git.deb
82
+
83
+ if [[ "#{repository}" =~ "@" ]]; then
84
+ # Get host key for src machine to prevent ssh from failing
85
+ rm -f ~/.ssh/known_hosts
86
+ ! ssh -o 'StrictHostKeyChecking=no' #{repository.gsub(/:.*/, '')} &> /dev/null
87
+ fi
38
88
  fi
39
89
  ENDSCRIPT
40
90
  end
@@ -121,10 +121,13 @@ assigned_security_groups: [default]
121
121
  # creation, so its good to have some empty ones predefined.
122
122
  auto_security_groups: true
123
123
 
124
+ # OPTIONAL: Set if you want to use Ruby Enterprise Edition instead of the standard ubuntu one
125
+ use_enterprise_ruby: false
126
+
124
127
  # OPTIONAL: The packages to install on all instances
125
128
  # You can install a specific version of a package by using a sub-array of pkg, version
126
129
  # For example, packages: [[rake, 0.7.1], irb]
127
- packages: [build-essential, ruby-full, ruby1.8-dev, rake, irb, subversion]
130
+ packages: [build-essential, ruby-full, ruby1.8-dev, rake, irb]
128
131
 
129
132
  # OPTIONAL: The gems to install on all instances
130
133
  # You can install a specific version of a gem by using a sub-array of gem, version
@@ -9,13 +9,13 @@ namespace :rubber do
9
9
 
10
10
  task :custom_install, :roles => :web do
11
11
  rubber.sudo_script 'install_passenger', <<-ENDSCRIPT
12
- echo -en "\n\n\n\n" | passenger-install-apache2-module
13
- wget -q http://rubyforge.org/frs/download.php/58679/ruby-enterprise_1.8.6-20090610_i386.deb
14
- dpkg -i ruby-enterprise_1.8.6-20090610_i386.deb
15
- # disable ubuntu default site
16
- a2dissite default
12
+ if [[ ! -f /usr/lib/ruby/gems/*/gems/passenger-*/ext/apache2/mod_passenger.so ]]; then
13
+ echo -en "\n\n\n\n" | passenger-install-apache2-module
14
+ # disable ubuntu default site
15
+ a2dissite default
16
+ fi
17
17
  ENDSCRIPT
18
- end
18
+ end
19
19
 
20
20
  # serial_task can only be called after roles defined - not normally a problem, but
21
21
  # rubber auto-roles don't get defined till after all tasks are defined
@@ -48,5 +48,17 @@ namespace :rubber do
48
48
  serial_reload
49
49
  end
50
50
 
51
+ deploy.task :restart, :roles => :web do
52
+ rubber.passenger.restart
53
+ end
54
+
55
+ deploy.task :stop, :roles => :web do
56
+ rubber.passenger.stop
57
+ end
58
+
59
+ deploy.task :start, :roles => :web do
60
+ rubber.passenger.start
61
+ end
62
+
51
63
  end
52
64
  end
@@ -4,7 +4,9 @@
4
4
  %>
5
5
  <VirtualHost *:80>
6
6
  ServerName <%= rubber_env.domain %>
7
+ <%- if rubber_env.web_aliases -%>
7
8
  ServerAlias <%= rubber_env.web_aliases.join(" ") %>
9
+ <%- end -%>
8
10
  DocumentRoot <%= RUBBER_ROOT + "/public" %>
9
11
 
10
12
  ErrorDocument 404 /404.html
@@ -1,4 +1,14 @@
1
+ security_groups:
2
+ web:
3
+ description: To open up port 80 for http server on web role
4
+ rules:
5
+ - protocol: tcp
6
+ from_port: 80
7
+ to_port: 80
8
+ source_ips: [0.0.0.0/0]
9
+
1
10
  roles:
2
11
  web:
3
- packages: [apache2-mpm-prefork apache2-prefork-dev]
12
+ packages: [apache2-mpm-prefork, apache2-prefork-dev]
4
13
  gems: [fastthread, rack, [passenger, 2.2.4]]
14
+ assigned_security_groups: [web]
@@ -1,7 +1,7 @@
1
1
  require 'fileutils'
2
2
  require 'date'
3
3
  require 'time'
4
-
4
+ require 'aws/s3'
5
5
  require 'rubber'
6
6
 
7
7
  namespace :rubber do
@@ -14,9 +14,12 @@ namespace :rubber do
14
14
  Rubber::Configuration.rubber_instances
15
15
  end
16
16
 
17
+ def cloud_provider
18
+ rubber_env.cloud_providers[rubber_env.cloud_provider]
19
+ end
20
+
17
21
  def init_s3()
18
- env = rubber_env
19
- AWS::S3::Base.establish_connection!(:access_key_id => env.aws_access_key, :secret_access_key => env.aws_secret_access_key)
22
+ AWS::S3::Base.establish_connection!(:access_key_id => cloud_provider.access_key, :secret_access_key => cloud_provider.secret_access_key)
20
23
  end
21
24
 
22
25
  desc "Generate system config files by transforming the files in the config tree"
@@ -127,7 +130,7 @@ namespace :rubber do
127
130
  puts "Created backup: #{backup_file}"
128
131
 
129
132
  s3_prefix = "db/"
130
- backup_bucket = rubber_env.cloud_providers[env.cloud_provider].backup_bucket
133
+ backup_bucket = cloud_provider.backup_bucket
131
134
  if backup_bucket
132
135
  init_s3
133
136
  unless AWS::S3::Bucket.list.find { |b| b.name == backup_bucket }
@@ -183,7 +186,7 @@ namespace :rubber do
183
186
  db_restore_cmd = eval('%Q{' + db_restore_cmd + '}')
184
187
 
185
188
  # try to fetch a matching file from s3 (if backup_bucket given)
186
- backup_bucket = rubber_env.cloud_providers[env.cloud_provider].backup_bucket
189
+ backup_bucket = cloud_provider.backup_bucket
187
190
  raise "No backup_bucket defined in rubber.yml" unless backup_bucket
188
191
  if (init_s3 &&
189
192
  AWS::S3::Bucket.list.find { |b| b.name == backup_bucket })
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sml-rubber
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.4
4
+ version: 0.9.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Conway
@@ -9,8 +9,8 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-07 00:00:00 -07:00
13
- default_executable:
12
+ date: 2009-08-18 00:00:00 -07:00
13
+ default_executable: vulcanize
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: capistrano
@@ -64,8 +64,8 @@ dependencies:
64
64
  version:
65
65
  description: "The rubber plugin enables relatively complex multi-instance deployments of RubyOnRails applications to Amazon\xD5s Elastic Compute Cloud (EC2). Like capistrano, rubber is role based, so you can define a set of configuration files for a role and then assign that role to as many concrete instances as needed. One can also assign multiple roles to a single instance. This lets one start out with a single ec2 instance (belonging to all roles), and add new instances into the mix as needed to scale specific facets of your deployment, e.g. adding in instances that serve only as an 'app' role to handle increased app server load."
66
66
  email: matt@conwaysplace.com
67
- executables: []
68
-
67
+ executables:
68
+ - vulcanize
69
69
  extensions: []
70
70
 
71
71
  extra_rdoc_files:
@@ -75,6 +75,7 @@ files:
75
75
  - README
76
76
  - TODO
77
77
  - VERSION
78
+ - bin/vulcanize
78
79
  - generators/vulcanize/USAGE
79
80
  - generators/vulcanize/templates/apache/config/rubber/deploy-apache.rb
80
81
  - generators/vulcanize/templates/apache/config/rubber/role/web/deflate.conf