Browse Source

Add passenger_apache2 recipe for application cookbook

jtimberman 14 years ago
parent
commit
04cf09d88f
4 changed files with 72 additions and 7 deletions
  1. 13 0
      README.md
  2. 7 5
      metadata.json
  3. 2 2
      metadata.rb
  4. 50 0
      recipes/passenger_apache2.rb

+ 13 - 0
README.md

@@ -19,6 +19,7 @@ The following Opscode cookbooks are dependencies:
 
 * runit
 * unicorn
+* apache2
 
 The following are also dependencies, though the recipes are considered deprecated, may be useful for future development.
 
@@ -38,6 +39,18 @@ Searches the `apps` data bag and checks that a server role in the app exists on
 
 See below regarding the application data bag structure.
 
+passenger_apache2
+-----------------
+
+Requires `apache2` and `passenger_apache2` cookbooks. The `recipe[apache2]` entry should come before `recipe[application]` in the run list.
+
+    "run_list": [
+      "recipe[apache2]",
+      "recipe[application]"
+    ],
+
+Sets up a passenger vhost template for the application using the `apache2` cookbook's `web_app` definition. Use this with the `rails` recipe, in the list of recipes for a specific application type. See data bag example below.
+
 rails
 -----
 

File diff suppressed because it is too large
+ 7 - 5
metadata.json


+ 2 - 2
metadata.rb

@@ -3,8 +3,8 @@ maintainer_email "cookbooks@opscode.com"
 license          "Apache 2.0"
 description      "Deploys and configures a Rails application from databag 'apps'"
 long_description  IO.read(File.join(File.dirname(__FILE__), 'README.md'))
-version          "0.4"
+version          "0.5"
 
-%w{ ruby_enterprise passenger_enterprise runit unicorn }.each do |cb|
+%w{ ruby_enterprise passenger_enterprise runit unicorn apache2 passenger_apache2}.each do |cb|
   depends cb
 end

+ 50 - 0
recipes/passenger_apache2.rb

@@ -0,0 +1,50 @@
+#
+# Cookbook Name:: application
+# Recipe:: passenger_apache2
+#
+# Copyright 2010, Opscode, Inc.
+#
+# 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.
+#
+
+app = node.run_state[:current_app] 
+
+include_recipe "apache2"
+include_recipe "apache2::mod_ssl"
+include_recipe "apache2::mod_rewrite"
+include_recipe "passenger_apache2::mod_rails"
+
+server_aliases = [ "#{app['id']}.#{node[:domain]}", node.fqdn ]
+
+if node.has_key?("ec2")
+  server_aliases << node.ec2.public_hostname
+end
+  
+web_app app['id'] do
+  docroot "#{app['deploy_to']}/current/public"
+  template "#{app['id']}.conf.erb"
+  cookbook "#{app['id']}"
+  server_name "#{app['id']}.#{node[:domain]}"
+  server_aliases server_aliases
+  log_dir node[:apache][:log_dir]
+  rails_env node.app_environment
+end
+
+d = resources(:deploy => app['id'])
+d.restart_command do
+  service "apache2" do action :restart; end
+end
+
+apache_site "000-default" do
+  enable false
+end

Some files were not shown because too many files changed in this diff