Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

recipe tweaks for rails quick start guide

  • Loading branch information...
commit 7632a216d96de6e2b58ecf9adff805c350c1efb1 1 parent 4c9b71a
@jtimberman jtimberman authored
View
35 application/README.md
@@ -39,8 +39,8 @@ 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
------------------
+`passenger_apache2`
+-------------------
Requires `apache2` and `passenger_apache2` cookbooks. The `recipe[apache2]` entry should come before `recipe[application]` in the run list.
@@ -59,8 +59,33 @@ Using the node's `run_state` that contains the current application in the search
This recipe can be used on nodes that are going to run the application, or on nodes that need to have the application code checkout available such as supporting utility nodes or a configured load balancer that needs static assets stored in the application repository.
For Gem Bundler: include `bundler` or `bundler08` in the gems list. `bundle install` or `gem bundle` will be run before migrations.
+
For config.gem in environment: `rake gems:install RAILS_ENV=<node environment>` will be run when a Gem Bundler command is not.
+In order to manage running database migrations (rake db:migrate), you can use a role that sets the `run_migrations` attribute for the application (`my_app`, below) in the correct environment (production, below). Note the data bag item needs to have migrate set to true. See the data bag example below.
+
+ {
+ "name": "my_app_run_migrations",
+ "description": "Run db:migrate on demand for my_app",
+ "json_class": "Chef::Role",
+ "default_attributes": {
+ },
+ "override_attributes": {
+ "apps": {
+ "my_app": {
+ "production": {
+ "run_migrations": true
+ }
+ }
+ }
+ },
+ "chef_type": "role",
+ "run_list": [
+ ]
+ }
+
+Simply apply this role to the node's run list when it is time to run migrations, and the recipe will remove the role when done.
+
unicorn
-------
@@ -79,8 +104,8 @@ passenger-nginx
Builds passenger as an nginx module, drops off the configuration file and sets up the site to run the application under nginx with passenger. Does not deploy the code automatically.
-rails_nginx_ree_passenger
--------------------------
+`rails_nginx_ree_passenger`
+---------------------------
Sets up the application stack with Ruby Enterprise Edition, Nginx and Passenger.
@@ -197,7 +222,7 @@ To use the application cookbook, we recommend creating a role named after the ap
}
}
-Also recommended is a site-cookbook named after the application, e.g. `my_app`, for additional application specific setup such as other config files for queues, search engines and other components of your application. The `my_app` recipe can be used in the run list of the role, if it includes the `application` recipe.
+Also recommended is a cookbook named after the application, e.g. `my_app`, for additional application specific setup such as other config files for queues, search engines and other components of your application. The `my_app` recipe can be used in the run list of the role, if it includes the `application` recipe.
You should also have a role for the environment(s) you wish to use this cookbook. Similar to the role above, create the Ruby DSL file in chef-repo, or create with knife directly.
View
2  application/metadata.rb
@@ -3,7 +3,7 @@
license "Apache 2.0"
description "Deploys and configures a variety of applications defined from databag 'apps'"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
-version "0.6.3"
+version "0.7.0"
recipe "application", "Loads application databags and selects recipes to use"
recipe "application::passenger-nginx", "Installs Ruby Enterprise with Passenger under Nginx"
recipe "application::passenger_apache2", "Sets up a deployed Rails application as a Passenger virtual host in Apache2"
View
12 application/recipes/rails.rb
@@ -203,8 +203,18 @@
if app['migrate'][node.app_environment] && node[:apps][app['id']][node.app_environment][:run_migrations]
migrate true
- migration_command "rake db:migrate"
+ migration_command app['migration_command'] || "rake db:migrate"
else
migrate false
end
+ before_symlink do
+ ruby_block "remove_run_migrations" do
+ block do
+ if node.role?("#{app['id']}_run_migrations")
+ Chef::Log.info("Migrations were run, removing role[#{app['id']}_run_migrations]")
+ node.run_list.remove("role[#{app['id']}_run_migrations]")
+ end
+ end
+ end
+ end
end
View
4 radiant/README.rdoc
@@ -12,6 +12,8 @@ Tested on Ubuntu 9.04, uses the Opscode Apache2 cookbook which is Ubuntu/Debian
Requires Chef 0.7.12 for Deploy resource when installing from Radiant's git repo.
+The `db_bootstrap` recipe requires Chef 0.9.10+ for the notifies resource syntax.
+
== Cookbooks:
Opscode cookbooks (http://github.com/opscode/cookbooks/tree/master)
@@ -56,7 +58,7 @@ This task will destroy any data in the database. Are you sure you want to contin
This recipe wraps the rake db:bootstrap from above. Only use this recipe if you know what you are doing. Otherwise, run the db:bootstrap manually.
-This recipe is designed to be used with the Opscode application cookbook, and only one time.
+This recipe is designed to be used with the Opscode application cookbook, and only one time. It removes itself with a Ruby block resource when the rake resource executes successfully.
= LICENSE and AUTHOR:
View
2  radiant/metadata.rb
@@ -3,7 +3,7 @@
license "Apache 2.0"
description "Installs radiant from Git repository"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc'))
-version "0.11.2"
+version "0.11.3"
recipe "radiant", "Installs Radiant CMS"
recipe "radiant::db_bootstrap", "Bootstrap the Radiant database, used with application cookbook (destructive)"
View
10 radiant/recipes/db_bootstrap.rb
@@ -44,10 +44,20 @@
execute "db_bootstrap" do
command node[:radiant][:db_bootstrap]
cwd "#{app['deploy_to']}/current"
+ creates "#{app['deploy_to']}/current/tmp/radiant_config_cache.txt"
ignore_failure true
+ notifies :create, "ruby_block[remove_radiant_bootstrap]", :immediately
end
file "#{app['deploy_to']}/current/tmp/radiant_config_cache.txt" do
owner app['owner']
group app['group']
end
+
+ruby_block "remove_radiant_bootstrap" do
+ block do
+ Chef::Log.info("Radiant Database Bootstrap completed, removing the destructive recipe[radiant::db_bootstrap]")
+ node.run_list.remove("recipe[radiant::db_bootstrap]") if node.run_list.include?("recipe[radiant::db_bootstrap]")
+ end
+ action :nothing
+end
Please sign in to comment.
Something went wrong with that request. Please try again.