Application cookbook w/ Rails app


#1

I’m trying to deploy a Rails app using the new application cookbook. According to the README, I’m supposed to declare a dependency on the application_rails cookbook in the metadata.rb, but that doesn’t seem to exist. Earlier in the README, application_ruby is mentioned, so I switched it to that. Do we need a documentation fix there?

Anyway, I can’t quite figure out how the rails-y portion of the cookbook is supposed to be invoked. Just declaring a “depends” line in metadata.rb doesn’t actually run anything, does it?

I see in the examples that there is a rails do … end block in the application’s block. Is that what triggers it?

Does anyone have a working example of deploying a Rails app w/ the new application cookbook?

Wes


#2

Did you read the README in application_ruby?

On Jul 21, 2012, at 7:09 PM, Wes Morgan cap10morgan@gmail.com wrote:

I’m trying to deploy a Rails app using the new application cookbook. According to the README, I’m supposed to declare a dependency on the application_rails cookbook in the metadata.rb, but that doesn’t seem to exist. Earlier in the README, application_ruby is mentioned, so I switched it to that. Do we need a documentation fix there?

Anyway, I can’t quite figure out how the rails-y portion of the cookbook is supposed to be invoked. Just declaring a “depends” line in metadata.rb doesn’t actually run anything, does it?

I see in the examples that there is a rails do … end block in the application’s block. Is that what triggers it?

Does anyone have a working example of deploying a Rails app w/ the new application cookbook?

Wes


#3

Hi, take a look into https://github.com/iafonov/stacker. This is
boilerplate chef repository I’m using to deploy rails applications. It has
working example and uses application and application_ruby cookbooks.

Particulary you could be interested in the following things:
Deploy recipe:
https://github.com/iafonov/stacker/blob/master/vendor-cookbooks/copycopter/recipes/deploy.rb
Application’s cookbook:
https://github.com/iafonov/stacker/tree/master/vendor-cookbooks/copycopter

Also I’ve open sourced a cookbook for managing deployment of several rails
applications, you can take a look into it here:

Hope it helps!
Igor

On Sat, Jul 21, 2012 at 8:09 PM, Wes Morgan cap10morgan@gmail.com wrote:

I’m trying to deploy a Rails app using the new application cookbook.
According to the README, I’m supposed to declare a dependency on the
application_rails cookbook in the metadata.rb, but that doesn’t seem to
exist. Earlier in the README, application_ruby is mentioned, so I switched
it to that. Do we need a documentation fix there?

Anyway, I can’t quite figure out how the rails-y portion of the cookbook
is supposed to be invoked. Just declaring a “depends” line in metadata.rb
doesn’t actually run anything, does it?

I see in the examples that there is a rails do … end block in the
application’s block. Is that what triggers it?

Does anyone have a working example of deploying a Rails app w/ the new
application cookbook?

Wes


#4

Correct, you need the ruby do block.

I have a cookbook for my application, which has

depends “application_ruby”

in its metadata.rb, and then in its default recipe, has this (as an
example):

application “zmx_app” do
path "/srv/zmx"
owner 'nobody’
group ‘nogroup’

repository 'git@github.com:zmxmusic/zmx2.git’
deploy_key “-----BEGIN RSA PRIVATE KEY----- …etc… -----END RSA
PRIVATE KEY-----\n” # note embedded newlines
if node.chef_environment=='production’
revision '2.26’
action :deploy
else
revision 'master’
action :force_deploy
end

db = “zmx_#{node.chef_environment}”

rails do
gems [‘bundler’]
precompile_assets true
database do
reconnect true
encoding 'utf8’
username '…'
adapter 'mysql2’
password '…'
database db
end
database_master_role "zmx_database_master"
end

passenger_apache2 do
end
end

There might well be better ways to do it; I migrated up from the old
cookbook. My apache/passenger config is really done in other recipes; one
of these days I’ll take care of that and probably migrate to unicorn,
nginx, etc.

Don’t know what you’re using for database. I had to wrestle mightily with
the mysql (and database?) cookbooks to get a working set of
cookbooks+recipes that would come up from scratch on AWS… I’m not even
convinced I’ve actually got that, yet, but needed to move on and get stuff
done.


Denis Haskin

On Sat, Jul 21, 2012 at 1:09 PM, Wes Morgan cap10morgan@gmail.com wrote:

I’m trying to deploy a Rails app using the new application cookbook.
According to the README, I’m supposed to declare a dependency on the
application_rails cookbook in the metadata.rb, but that doesn’t seem to
exist. Earlier in the README, application_ruby is mentioned, so I switched
it to that. Do we need a documentation fix there?

Anyway, I can’t quite figure out how the rails-y portion of the cookbook
is supposed to be invoked. Just declaring a “depends” line in metadata.rb
doesn’t actually run anything, does it?

I see in the examples that there is a rails do … end block in the
application’s block. Is that what triggers it?

Does anyone have a working example of deploying a Rails app w/ the new
application cookbook?

Wes


#5

Thanks for the insight and examples, Denis & Igor. I think I was being thrown off by the documentation errors and all the deprecated code in the application cookbook. It’s starting to come together now.

Wes

On Jul 21, 2012, at 12:20 PM, Denis Haskin wrote:

Correct, you need the ruby do block.

I have a cookbook for my application, which has

depends “application_ruby”

in its metadata.rb, and then in its default recipe, has this (as an example):

application “zmx_app” do
path "/srv/zmx"
owner 'nobody’
group ‘nogroup’

repository 'git@github.com:zmxmusic/zmx2.git’
deploy_key “-----BEGIN RSA PRIVATE KEY----- …etc… -----END RSA PRIVATE KEY-----\n” # note embedded newlines
if node.chef_environment=='production’
revision '2.26’
action :deploy
else
revision 'master’
action :force_deploy
end

db = “zmx_#{node.chef_environment}”

rails do
gems [‘bundler’]
precompile_assets true
database do
reconnect true
encoding 'utf8’
username '…'
adapter 'mysql2’
password '…'
database db
end
database_master_role "zmx_database_master"
end

passenger_apache2 do
end
end

There might well be better ways to do it; I migrated up from the old cookbook. My apache/passenger config is really done in other recipes; one of these days I’ll take care of that and probably migrate to unicorn, nginx, etc.

Don’t know what you’re using for database. I had to wrestle mightily with the mysql (and database?) cookbooks to get a working set of cookbooks+recipes that would come up from scratch on AWS… I’m not even convinced I’ve actually got that, yet, but needed to move on and get stuff done.


Denis Haskin

On Sat, Jul 21, 2012 at 1:09 PM, Wes Morgan cap10morgan@gmail.com wrote:
I’m trying to deploy a Rails app using the new application cookbook. According to the README, I’m supposed to declare a dependency on the application_rails cookbook in the metadata.rb, but that doesn’t seem to exist. Earlier in the README, application_ruby is mentioned, so I switched it to that. Do we need a documentation fix there?

Anyway, I can’t quite figure out how the rails-y portion of the cookbook is supposed to be invoked. Just declaring a “depends” line in metadata.rb doesn’t actually run anything, does it?

I see in the examples that there is a rails do … end block in the application’s block. Is that what triggers it?

Does anyone have a working example of deploying a Rails app w/ the new application cookbook?

Wes


#6

Good to hear. Fork, fix, and submit a pull request!

Sent from mobile
On Jul 21, 2012 3:02 PM, “Wes Morgan” cap10morgan@gmail.com wrote:

Thanks for the insight and examples, Denis & Igor. I think I was being
thrown off by the documentation errors and all the deprecated code in the
application cookbook. It’s starting to come together now.

Wes

On Jul 21, 2012, at 12:20 PM, Denis Haskin wrote:

Correct, you need the ruby do block.

I have a cookbook for my application, which has

depends “application_ruby”

in its metadata.rb, and then in its default recipe, has this (as an
example):

application “zmx_app” do
path "/srv/zmx"
owner 'nobody’
group ‘nogroup’

repository 'git@github.com:zmxmusic/zmx2.git’
deploy_key “-----BEGIN RSA PRIVATE KEY----- …etc… -----END RSA
PRIVATE KEY-----\n” # note embedded newlines
if node.chef_environment=='production’
revision '2.26’
action :deploy
else
revision 'master’
action :force_deploy
end

db = “zmx_#{node.chef_environment}”

rails do
gems [‘bundler’]
precompile_assets true
database do
reconnect true
encoding 'utf8’
username '…'
adapter 'mysql2’
password '…'
database db
end
database_master_role "zmx_database_master"
end

passenger_apache2 do
end
end

There might well be better ways to do it; I migrated up from the old
cookbook. My apache/passenger config is really done in other recipes; one
of these days I’ll take care of that and probably migrate to unicorn,
nginx, etc.

Don’t know what you’re using for database. I had to wrestle mightily with
the mysql (and database?) cookbooks to get a working set of
cookbooks+recipes that would come up from scratch on AWS… I’m not even
convinced I’ve actually got that, yet, but needed to move on and get stuff
done.


Denis Haskin

On Sat, Jul 21, 2012 at 1:09 PM, Wes Morgan cap10morgan@gmail.com wrote:

I’m trying to deploy a Rails app using the new application cookbook.
According to the README, I’m supposed to declare a dependency on the
application_rails cookbook in the metadata.rb, but that doesn’t seem to
exist. Earlier in the README, application_ruby is mentioned, so I switched
it to that. Do we need a documentation fix there?

Anyway, I can’t quite figure out how the rails-y portion of the cookbook
is supposed to be invoked. Just declaring a “depends” line in metadata.rb
doesn’t actually run anything, does it?

I see in the examples that there is a rails do … end block in the
application’s block. Is that what triggers it?

Does anyone have a working example of deploying a Rails app w/ the new
application cookbook?

Wes