Configure/deploy multiples apps per cookbook, how?

Hello list,

I’m just starting out wtih Chef, and I’ve been playing with rather simple
scenarios using chef-server+EC2 and chef-solo/chef-server + Vagrant. So far
it has been awesome, and being able to document and configurate server(s)
in an idempotent way is simply a huge paradigm shift, for the better.

Now, I could be considered someone who doesn’t need to use Chef, since I
don’t deal with a lot of servers right now. In fact, I only have one EC2
slice for now, since most of my websites are Refinery CMS, static among a
few small Rails 3 apps. I don’t need to scale to more servers right now,
one is enough for multiple apps, and Chef is very useful in this scenario
as well, in order to have the server spec and being able to have an exact
copy locally with Vagrant, is priceless.

However, it looks like the multiple vhosts per server scenario is not a
popular one for Chef (and I guess because most of the heavy users probably
use one server per app), so it’s really hard to find clear information on
the subject.

Let’s say I have a local Vagrant VM running Ubuntu:

  • This VM will be provisioned and configured by Chef (solo or server) with
    nginx, runit and a directory layout like this:
    /srv/
    for the apps/websites. Also the Vagrant shared dir on my workstation
    would be ~/projects/; a dir where I keep all the code for my projects. This
    would be mapped to /srv/ in the VM.

  • Let’s say I have the VM ready. In my workstation, I would then create a
    new project, say, Rails-based, in ~/projects/mynewapp

  • I would then setup a virtualhost on my local machine, mynewapp.local,
    mapping to 127.0.0.1.

Now, I’d like to use Chef to provision the nginx virtualhost for this app
to the VM, and (optionally) deploy the code.

I’ve seen how to do that in the following article:

http://www.jasongrimes.org/2012/06/deploying-a-lamp-application-with-chef-vagrant-and-ec2-3-of-3/:bookmark:chef:

It’s a very good walkthrough, and although he sets up a LAMP instead of a
nginx/Ruby stack, it’s not hard to translate to using the nginx and Ruby.

However, let’s say next week I create two new Ruby apps. And then 3 static
websites. The amount of Chef recipes would scale pretty quickly and code
duplication as well, I’m afraid.

What I’d like to do is to have a cookbook for setting up the nginx/Ruby
stack VM; another one for Ruby/Rails apps, and another one for static
websites (say, jekyll blogs or simple static html sites directly served by
nginx), and have them be shared by several applications, in a way that I
wouldn’t need to duplicate them for each and every application/site I
create.

When one of those apps are deployed, Chef would check the state of the VM,
and if it’s already setup, it would add the necessary vhost to nginx (if
needed as well), and then deploy the code.

How would I go doing that with chef? If someone could enlighten me, I’d be
very grateful!

Thanks in advance,

  • Marcelo.

Hi guys,

Anyone out there? :slight_smile: If for some reason it wasn't clear, please let me
know. I'd really appreciate some insights.

Cheers,

  • Marcelo.

On Tue, Aug 14, 2012 at 11:18 PM, Marcelo de Moraes Serpa <
celoserpa@gmail.com> wrote:

Hello list,

I'm just starting out wtih Chef, and I've been playing with rather simple
scenarios using chef-server+EC2 and chef-solo/chef-server + Vagrant. So far
it has been awesome, and being able to document and configurate server(s)
in an idempotent way is simply a huge paradigm shift, for the better.

Now, I could be considered someone who doesn't need to use Chef, since I
don't deal with a lot of servers right now. In fact, I only have one EC2
slice for now, since most of my websites are Refinery CMS, static among a
few small Rails 3 apps. I don't need to scale to more servers right now,
one is enough for multiple apps, and Chef is very useful in this scenario
as well, in order to have the server spec and being able to have an exact
copy locally with Vagrant, is priceless.

However, it looks like the multiple vhosts per server scenario is not a
popular one for Chef (and I guess because most of the heavy users probably
use one server per app), so it's really hard to find clear information on
the subject.

Let's say I have a local Vagrant VM running Ubuntu:

  • This VM will be provisioned and configured by Chef (solo or server) with
    nginx, runit and a directory layout like this:
    /srv/
    for the apps/websites. Also the Vagrant shared dir on my workstation
    would be ~/projects/; a dir where I keep all the code for my projects. This
    would be mapped to /srv/ in the VM.

  • Let's say I have the VM ready. In my workstation, I would then create a
    new project, say, Rails-based, in ~/projects/mynewapp

  • I would then setup a virtualhost on my local machine, mynewapp.local,
    mapping to 127.0.0.1.

Now, I'd like to use Chef to provision the nginx virtualhost for this app
to the VM, and (optionally) deploy the code.

I've seen how to do that in the following article:

Scale your web app - Grimes IT, LLC

It's a very good walkthrough, and although he sets up a LAMP instead of a
nginx/Ruby stack, it's not hard to translate to using the nginx and Ruby.

However, let's say next week I create two new Ruby apps. And then 3 static
websites. The amount of Chef recipes would scale pretty quickly and code
duplication as well, I'm afraid.

What I'd like to do is to have a cookbook for setting up the nginx/Ruby
stack VM; another one for Ruby/Rails apps, and another one for static
websites (say, jekyll blogs or simple static html sites directly served by
nginx), and have them be shared by several applications, in a way that I
wouldn't need to duplicate them for each and every application/site I
create.

When one of those apps are deployed, Chef would check the state of the VM,
and if it's already setup, it would add the necessary vhost to nginx (if
needed as well), and then deploy the code.

How would I go doing that with chef? If someone could enlighten me, I'd be
very grateful!

Thanks in advance,

  • Marcelo.

On Thu, Aug 16, 2012 at 6:12 AM, Marcelo de Moraes Serpa
celoserpa@gmail.com wrote:

Hi guys,

Anyone out there? :slight_smile: If for some reason it wasn't clear, please let me know.
I'd really appreciate some insights.

It was pretty clear, it's just a question that doesn't lend itself to
a short, definitive answer :slight_smile:
So here is mine, and keep in mind it's just my own, and it's pretty opinionated.

Think of Chef cookbooks and recipes in terms of code ("infrastructure
as code" is IMHO an even more relevant buzzword that "devops" in this
context :wink: ).
If you have several, mostly unrelated applications, then surely it's
ok to have several, mostly unrelated Chef cookbooks. The number of
them shouldn't concern you so much, as long as they are manageable.
Just what "manageable" means in this context varies based on your
company, your understanding of Chef (and Ruby) and so on. You'll have
to find what works for you, best practices notwithstanding.

Your concern with code duplication however is more interesting.
If you think in terms of code, you'll want to factor out common
aspects of the application stacks you manage, and make them into
reusable pieces of Chef code.
Some existing cookbooks provide LWRPs for this; and you can write your own.

For Rails apps, look at the application cookbook and the matching
application_ruby.
Here is an example from a real app I'm deploying:

application "myapp" do
path node['myapp']['root']
owner "user"
group "group"
repository "git@git-repo:myapp.git"
deploy_key "——BEGIN RSA PRIVATE KEY——\n…\n——END RSA PRIVATE KEY——"
revision node.chef_environment == "production" ? "release/0.5"
: "develop"
migrate true

rails do
gems ["bundler"]
bundler_deployment true
precompile_assets true

database do
  adapter   "postgresql"
  database  "myapp"
  username  "myapp"
  password  "myapp"
end
database_master_role  "myapp_database_master"

end

passenger_apache2 do
webapp_template "myapp.conf.erb"
end
end

This resource uses the deploy resource you've probably read about in
that article you link to (checks out from git if changed, manages
symlinks similar to Capistrano etc).
In addition it will automatically do create database.yml, run a bundle
install, precompile assets for Rails3.
And finally, create your Apache vhost and restart Apache when necessary.

Regardless of the exact details, there is IMHO as little boilerplate
as can be; most of the arguments are really app-specific.
So when I have a new app to deploy, I just create a new cookbook with
something similar in its default recipe.
Similar apps will probably have recipes that are very similar; but the
difference are very important, and being able to see all vital aspects
of that app at a glance trumps DRYness.

That said, there may be cases where you are deploying the same app (or
a very similar one) many times.
For instance I imagine your RefineryCMS instances will be mostly the same.
I also assume you are deploying multiple RefineryCMS instances on the
same server, otherwise it would be trivial :wink:

In that case, a common pattern is to make such a deployment data-driven.
You can store information about each separate instance info a data
bag, or in an Array attribute; it's up to you, and different people
will give you different answers.

Assuming you have a "refinerycms_instances" data bag, you would end up
with something like:

search(:refinerycms_instances) do |site|
if (site["server_roles"] & node.roles).any?
application "refinerycms: #{site["id"]}" do
repository "git@git-repo:refinerycms.git" # the same
for all instances, probably
path "/data/refinerycms/#{site["id"]}" # different
..
end
end
end

In this case you do have a single cookbook for all your
quasi-identical apps, at the cost of a little bit of extra ceremony.
It's still pretty readable, and it's still pretty easy to see what is
common to all instances and what is per-instance.
Unless you are going to deploy all apps to all nodes, you will need a
little bit of extra ceremony (see the "site["server_roles"] &
node.roles" line); but that's a small price to pay for this kind of
flexibility.

Hope this helps.
Andrea

Hi Marcelo,

I've already mentioned in this list but I have a cookbook which is basically what you need. It manages deployment of several very similar rails applications. As Andrea mentioned if you have different applications it is better to have a separate cookbooks for them. But for your case here is the cookbook - GitHub - iafonov/rails_ghetto: Chef cookbook intended for managing & deployment of multiple rack-based applications living on one server behind nginx. Supports asset pipeline right from the box.. I'm 100% sure that you'd have to change it for your needs. I'm not a big fan of data bags (this cookbook was initially created for chef-solo) but if you are - you can quite easily alter it to use data bags instead of attributes.

Thanks,
Igor

четверг, 16 августа 2012 г. в 07:12, Marcelo de Moraes Serpa написал:

Hi guys,

Anyone out there? :slight_smile: If for some reason it wasn't clear, please let me know. I'd really appreciate some insights.

Cheers,

  • Marcelo.

On Tue, Aug 14, 2012 at 11:18 PM, Marcelo de Moraes Serpa <celoserpa@gmail.com (mailto:celoserpa@gmail.com)> wrote:

Hello list,

I'm just starting out wtih Chef, and I've been playing with rather simple scenarios using chef-server+EC2 and chef-solo/chef-server + Vagrant. So far it has been awesome, and being able to document and configurate server(s) in an idempotent way is simply a huge paradigm shift, for the better.

Now, I could be considered someone who doesn't need to use Chef, since I don't deal with a lot of servers right now. In fact, I only have one EC2 slice for now, since most of my websites are Refinery CMS, static among a few small Rails 3 apps. I don't need to scale to more servers right now, one is enough for multiple apps, and Chef is very useful in this scenario as well, in order to have the server spec and being able to have an exact copy locally with Vagrant, is priceless.

However, it looks like the multiple vhosts per server scenario is not a popular one for Chef (and I guess because most of the heavy users probably use one server per app), so it's really hard to find clear information on the subject.

Let's say I have a local Vagrant VM running Ubuntu:

  • This VM will be provisioned and configured by Chef (solo or server) with nginx, runit and a directory layout like this:
    /srv/
    for the apps/websites. Also the Vagrant shared dir on my workstation would be ~/projects/; a dir where I keep all the code for my projects. This would be mapped to /srv/ in the VM.

  • Let's say I have the VM ready. In my workstation, I would then create a new project, say, Rails-based, in ~/projects/mynewapp

  • I would then setup a virtualhost on my local machine, mynewapp.local, mapping to 127.0.0.1.

Now, I'd like to use Chef to provision the nginx virtualhost for this app to the VM, and (optionally) deploy the code.

I've seen how to do that in the following article:

Scale your web app - Grimes IT, LLC :bookmark:chef:

It's a very good walkthrough, and although he sets up a LAMP instead of a nginx/Ruby stack, it's not hard to translate to using the nginx and Ruby.

However, let's say next week I create two new Ruby apps. And then 3 static websites. The amount of Chef recipes would scale pretty quickly and code duplication as well, I'm afraid.

What I'd like to do is to have a cookbook for setting up the nginx/Ruby stack VM; another one for Ruby/Rails apps, and another one for static websites (say, jekyll blogs or simple static html sites directly served by nginx), and have them be shared by several applications, in a way that I wouldn't need to duplicate them for each and every application/site I create.

When one of those apps are deployed, Chef would check the state of the VM, and if it's already setup, it would add the necessary vhost to nginx (if needed as well), and then deploy the code.

How would I go doing that with chef? If someone could enlighten me, I'd be very grateful!

Thanks in advance,

  • Marcelo.

Igor,

On Thu, Aug 16, 2012 at 9:36 AM, Igor Afonov afonov@gmail.com wrote:

Hi Marcelo,

I've already mentioned in this list but I have a cookbook which is basically
what you need. It manages deployment of several very similar rails
applications. As Andrea mentioned if you have different applications it is
better to have a separate cookbooks for them. But for your case here is the
cookbook - GitHub - iafonov/rails_ghetto: Chef cookbook intended for managing & deployment of multiple rack-based applications living on one server behind nginx. Supports asset pipeline right from the box.. I'm 100% sure that you'd
have to change it for your needs. I'm not a big fan of data bags (this
cookbook was initially created for chef-solo) but if you are - you can quite
easily alter it to use data bags instead of attributes.

I had a look at rails_ghetto some time ago and I like it. If anything,
it shows a big benefit of the "new" application cookbook: you were
able to reuse its LWRPs to add functionality on top.

One question though: how come you rolled your own nginx_sites_enable
instead of using application_nginx? Any missing functionality there?
At a cursory glance it looks like a perfect match, you just need to
specify your own template.
I.e. in your recipes/deploy.rb:

rails_applications do |name, app|
application name do

nginx do
template "nginx_site.erb"
cookbook_name "rails_ghetto"
end
end
end

And you'd be pretty much set.

Did you try that and hit any roadblock?

Andrea

Andrea,

Wow, thanks, I've totally missed that I can do it like that. I thought that there maybe a better way to do it but totally missed most obvious way.

Igor

Отправлено при помощи Sparrow (http://www.sparrowmailapp.com/?sig)

четверг, 16 августа 2012 г. в 11:38, Andrea Campi написал:

Igor,

On Thu, Aug 16, 2012 at 9:36 AM, Igor Afonov <afonov@gmail.com (mailto:afonov@gmail.com)> wrote:

Hi Marcelo,

I've already mentioned in this list but I have a cookbook which is basically
what you need. It manages deployment of several very similar rails
applications. As Andrea mentioned if you have different applications it is
better to have a separate cookbooks for them. But for your case here is the
cookbook - GitHub - iafonov/rails_ghetto: Chef cookbook intended for managing & deployment of multiple rack-based applications living on one server behind nginx. Supports asset pipeline right from the box.. I'm 100% sure that you'd
have to change it for your needs. I'm not a big fan of data bags (this
cookbook was initially created for chef-solo) but if you are - you can quite
easily alter it to use data bags instead of attributes.

I had a look at rails_ghetto some time ago and I like it. If anything,
it shows a big benefit of the "new" application cookbook: you were
able to reuse its LWRPs to add functionality on top.

One question though: how come you rolled your own nginx_sites_enable
instead of using application_nginx? Any missing functionality there?
At a cursory glance it looks like a perfect match, you just need to
specify your own template.
I.e. in your recipes/deploy.rb:

rails_applications do |name, app|
application name do

nginx do
template "nginx_site.erb"
cookbook_name "rails_ghetto"
end
end
end

And you'd be pretty much set.

Did you try that and hit any roadblock?

Andrea

Wow! Thanks for the comprehensive reply Andrea!

I'll try those suggestion tonight. @Igor, I'll check out rails_ghetto as
well! I'll share my experience here afterwards.

Meanwhile, I have a quick question regarding the approach of Bryan Baugher,
in this thread:

http://lists.opscode.com/sympa/arc/chef/2012-07/msg00355.html

How would that work?

Thank you very much again for the replies!

  • Marcelo.

On Thu, Aug 16, 2012 at 5:22 AM, Igor Afonov afonov@gmail.com wrote:

Andrea,

Wow, thanks, I've totally missed that I can do it like that. I thought
that there maybe a better way to do it but totally missed most obvious way.

Igor

Отправлено при помощи Sparrow http://www.sparrowmailapp.com/?sig

четверг, 16 августа 2012 г. в 11:38, Andrea Campi написал:

Igor,

On Thu, Aug 16, 2012 at 9:36 AM, Igor Afonov afonov@gmail.com wrote:

Hi Marcelo,

I've already mentioned in this list but I have a cookbook which is
basically
what you need. It manages deployment of several very similar rails
applications. As Andrea mentioned if you have different applications it is
better to have a separate cookbooks for them. But for your case here is the
cookbook - GitHub - iafonov/rails_ghetto: Chef cookbook intended for managing & deployment of multiple rack-based applications living on one server behind nginx. Supports asset pipeline right from the box.. I'm 100% sure that
you'd
have to change it for your needs. I'm not a big fan of data bags (this
cookbook was initially created for chef-solo) but if you are - you can
quite
easily alter it to use data bags instead of attributes.

I had a look at rails_ghetto some time ago and I like it. If anything,
it shows a big benefit of the "new" application cookbook: you were
able to reuse its LWRPs to add functionality on top.

One question though: how come you rolled your own nginx_sites_enable
instead of using application_nginx? Any missing functionality there?
At a cursory glance it looks like a perfect match, you just need to
specify your own template.
I.e. in your recipes/deploy.rb:

rails_applications do |name, app|
application name do
...
nginx do
template "nginx_site.erb"
cookbook_name "rails_ghetto"
end
end
end

And you'd be pretty much set.

Did you try that and hit any roadblock?

Andrea

Igor,

I've been trying to get rails_ghetto up and running in a test Vagrant VM,
but I'm having a hard time - mainly because I'm still quite new to all
those chef[solo] concepts, I'd say. If you could give me a hand, I'd be
really grateful. Here's the portion of my Vagrantfile that sets up the
chef-solo integration:

config.vm.provision :chef_solo do |chef|
chef.cookbooks_path =
"/Users/fullofcaffeine/workspace/code/chef-repo/cookbooks"
chef.roles_path =
"/Users/fullofcaffeine/workspace/code/chef-repo/roles"
chef.data_bags_path =
"/Users/fullofcaffeine/workspace/code/chef-repo/data_bags"
#run list
chef.add_recipe("rails_ghetto::user")
chef.add_recipe("rails_ghetto::deploy")
chef.add_recipe("rails_ghetto::nginx_sites_enable")

#chef.add_recipe("php")
chef.json = { "rails_ghetto" => {
"deployment_user" => "deploy",
 "deployment_group" => "deploy",
 "apps_root" => "/var/www/apps",
 "libs" => ["libxslt-dev","libxml2-dev"],
 "applications" => {"sample" => {
      "repository" => "git@github.com:fullofcaffeine/raks.git",
      "revision" => "master",
      "deploy_key" => "/home/root/.ssh/github",
      "unicorn_port" => "8080",
      "server_name" => "production.example.com",
      "compile_assets" => "true",
      "run_migrations" => "true",
      "rails_environment" => "production",
       "database" => { "adapter" => "postgresql",
                       "database" => "sample2",
                       "username" => "root",
                       "password" => "changeit" },
       }
      },
     "recipes" =>

["rails_ghetto::user","rails_ghetto::deploy","rails_ghetto::nginx_sites_enable"]
}
}

end

There are some fields that I need to change, but I wanted to let it run
first and then start the trial and error. However, it just fails with a
message that I can't interpet (tried googling but didn't find anything
useful). Here's the stacktrace:

Generated at Mon Sep 10 06:03:34 +0000 2012

*NameError: Cannot find a resource for application on ubuntu version 12.04
*
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/resource_platform_map.rb:129:in
get' /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/resource.rb:667:in resource_for_platform'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/resource.rb:684:in
resource_for_node' /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/mixin/recipe_definition_dsl_core.rb:58:in method_missing'
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/rails_ghetto/recipes/deploy.rb:9:in
from_file' /tmp/vagrant-chef-1/chef-solo-1/cookbooks/rails_ghetto/libraries/default.rb:7:in call'
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/rails_ghetto/libraries/default.rb:7:in
rails_applications' /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/node/attribute.rb:136:in call'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/node/attribute.rb:136:in
each' /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/node/attribute.rb:129:in each'
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/rails_ghetto/libraries/default.rb:4:in
rails_applications' /tmp/vagrant-chef-1/chef-solo-1/cookbooks/rails_ghetto/recipes/deploy.rb:8:in from_file'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/cookbook_version.rb:578:in
load_recipe' /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/mixin/language_include_recipe.rb:46:in load_recipe'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/mixin/language_include_recipe.rb:33:in
include_recipe' /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/mixin/language_include_recipe.rb:27:in each'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/mixin/language_include_recipe.rb:27:in
include_recipe' /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/run_context.rb:72:in load'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/run_context.rb:69:in
each' /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/run_context.rb:69:in load'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/client.rb:199:in
setup_run_context' /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/client.rb:162:in run'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/application/solo.rb:207:in
run_application' /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/application/solo.rb:195:in loop'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/application/solo.rb:195:in
run_application' /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/application.rb:70:in run'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/chef-solo:25
/opt/vagrant_ruby/bin/chef-solo:19:in `load'
/opt/vagrant_ruby/bin/chef-solo:19

Any ideas?

Thanks in advance!

  • Marcelo.

On Thu, Aug 16, 2012 at 8:56 PM, Marcelo de Moraes Serpa <
celoserpa@gmail.com> wrote:

Wow! Thanks for the comprehensive reply Andrea!

I'll try those suggestion tonight. @Igor, I'll check out rails_ghetto as
well! I'll share my experience here afterwards.

Meanwhile, I have a quick question regarding the approach of Bryan
Baugher, in this thread:

chef - [chef] RE: Re: Multiple application instances on a node

How would that work?

Thank you very much again for the replies!

  • Marcelo.

On Thu, Aug 16, 2012 at 5:22 AM, Igor Afonov afonov@gmail.com wrote:

Andrea,

Wow, thanks, I've totally missed that I can do it like that. I thought
that there maybe a better way to do it but totally missed most obvious way.

Igor

Отправлено при помощи Sparrow http://www.sparrowmailapp.com/?sig

четверг, 16 августа 2012 г. в 11:38, Andrea Campi написал:

Igor,

On Thu, Aug 16, 2012 at 9:36 AM, Igor Afonov afonov@gmail.com wrote:

Hi Marcelo,

I've already mentioned in this list but I have a cookbook which is
basically
what you need. It manages deployment of several very similar rails
applications. As Andrea mentioned if you have different applications it is
better to have a separate cookbooks for them. But for your case here is
the
cookbook - GitHub - iafonov/rails_ghetto: Chef cookbook intended for managing & deployment of multiple rack-based applications living on one server behind nginx. Supports asset pipeline right from the box.. I'm 100% sure that
you'd
have to change it for your needs. I'm not a big fan of data bags (this
cookbook was initially created for chef-solo) but if you are - you can
quite
easily alter it to use data bags instead of attributes.

I had a look at rails_ghetto some time ago and I like it. If anything,
it shows a big benefit of the "new" application cookbook: you were
able to reuse its LWRPs to add functionality on top.

One question though: how come you rolled your own nginx_sites_enable
instead of using application_nginx? Any missing functionality there?
At a cursory glance it looks like a perfect match, you just need to
specify your own template.
I.e. in your recipes/deploy.rb:

rails_applications do |name, app|
application name do

nginx do
template "nginx_site.erb"
cookbook_name "rails_ghetto"
end
end
end

And you'd be pretty much set.

Did you try that and hit any roadblock?

Andrea

On 10 September 2012 18:13, Marcelo de Moraes Serpa celoserpa@gmail.com wrote:

Igor,

I've been trying to get rails_ghetto up and running in a test Vagrant VM,
but I'm having a hard time - mainly because I'm still quite new to all those
chef[solo] concepts, I'd say. If you could give me a hand, I'd be really
grateful. Here's the portion of my Vagrantfile that sets up the chef-solo
integration:

config.vm.provision :chef_solo do |chef|
chef.cookbooks_path =
"/Users/fullofcaffeine/workspace/code/chef-repo/cookbooks"
chef.roles_path =
"/Users/fullofcaffeine/workspace/code/chef-repo/roles"
chef.data_bags_path =
"/Users/fullofcaffeine/workspace/code/chef-repo/data_bags"
#run list
chef.add_recipe("rails_ghetto::user")
chef.add_recipe("rails_ghetto::deploy")
chef.add_recipe("rails_ghetto::nginx_sites_enable")

#chef.add_recipe("php")
chef.json = { "rails_ghetto" => {
"deployment_user" => "deploy",
 "deployment_group" => "deploy",
 "apps_root" => "/var/www/apps",
 "libs" => ["libxslt-dev","libxml2-dev"],
 "applications" => {"sample" => {
      "repository" => "git@github.com:fullofcaffeine/raks.git",
      "revision" => "master",
      "deploy_key" => "/home/root/.ssh/github",
      "unicorn_port" => "8080",
      "server_name" => "production.example.com",
      "compile_assets" => "true",
      "run_migrations" => "true",
      "rails_environment" => "production",
       "database" => { "adapter" => "postgresql",
                       "database" => "sample2",
                       "username" => "root",
                       "password" => "changeit" },
       }
      },
     "recipes" =>

["rails_ghetto::user","rails_ghetto::deploy","rails_ghetto::nginx_sites_enable"]
}
}

end

There are some fields that I need to change, but I wanted to let it run
first and then start the trial and error. However, it just fails with a
message that I can't interpet (tried googling but didn't find anything
useful). Here's the stacktrace:

Generated at Mon Sep 10 06:03:34 +0000 2012
NameError: Cannot find a resource for application on ubuntu version 12.04

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/resource_platform_map.rb:129:in
`get'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/resource.rb:667:in
`resource_for_platform'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/resource.rb:684:in
`resource_for_node'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/mixin/recipe_definition_dsl_core.rb:58:in
`method_missing'

/tmp/vagrant-chef-1/chef-solo-1/cookbooks/rails_ghetto/recipes/deploy.rb:9:in
`from_file'

Looks like this recipe here ^ is calling an "application" local ivar
or resource which doesn't exist, on line 9.

HTH

--AJ

/tmp/vagrant-chef-1/chef-solo-1/cookbooks/rails_ghetto/libraries/default.rb:7:in
`call'

/tmp/vagrant-chef-1/chef-solo-1/cookbooks/rails_ghetto/libraries/default.rb:7:in
`rails_applications'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/node/attribute.rb:136:in
`call'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/node/attribute.rb:136:in
`each'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/node/attribute.rb:129:in
`each'

/tmp/vagrant-chef-1/chef-solo-1/cookbooks/rails_ghetto/libraries/default.rb:4:in
`rails_applications'

/tmp/vagrant-chef-1/chef-solo-1/cookbooks/rails_ghetto/recipes/deploy.rb:8:in
`from_file'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/cookbook_version.rb:578:in
`load_recipe'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/mixin/language_include_recipe.rb:46:in
`load_recipe'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/mixin/language_include_recipe.rb:33:in
`include_recipe'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/mixin/language_include_recipe.rb:27:in
`each'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/mixin/language_include_recipe.rb:27:in
`include_recipe'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/run_context.rb:72:in
`load'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/run_context.rb:69:in
`each'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/run_context.rb:69:in
`load'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/client.rb:199:in
`setup_run_context'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/client.rb:162:in
`run'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/application/solo.rb:207:in
`run_application'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/application/solo.rb:195:in
`loop'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/application/solo.rb:195:in
`run_application'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/application.rb:70:in
run' /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/chef-solo:25 /opt/vagrant_ruby/bin/chef-solo:19:in load'
/opt/vagrant_ruby/bin/chef-solo:19

Any ideas?

Thanks in advance!

  • Marcelo.

On Thu, Aug 16, 2012 at 8:56 PM, Marcelo de Moraes Serpa
celoserpa@gmail.com wrote:

Wow! Thanks for the comprehensive reply Andrea!

I'll try those suggestion tonight. @Igor, I'll check out rails_ghetto as
well! I'll share my experience here afterwards.

Meanwhile, I have a quick question regarding the approach of Bryan
Baugher, in this thread:

chef - [chef] RE: Re: Multiple application instances on a node

How would that work?

Thank you very much again for the replies!

  • Marcelo.

On Thu, Aug 16, 2012 at 5:22 AM, Igor Afonov afonov@gmail.com wrote:

Andrea,

Wow, thanks, I've totally missed that I can do it like that. I thought
that there maybe a better way to do it but totally missed most obvious way.

Igor

Отправлено при помощи Sparrow

четверг, 16 августа 2012 г. в 11:38, Andrea Campi написал:

Igor,

On Thu, Aug 16, 2012 at 9:36 AM, Igor Afonov afonov@gmail.com wrote:

Hi Marcelo,

I've already mentioned in this list but I have a cookbook which is
basically
what you need. It manages deployment of several very similar rails
applications. As Andrea mentioned if you have different applications it
is
better to have a separate cookbooks for them. But for your case here is
the
cookbook - GitHub - iafonov/rails_ghetto: Chef cookbook intended for managing & deployment of multiple rack-based applications living on one server behind nginx. Supports asset pipeline right from the box.. I'm 100% sure that
you'd
have to change it for your needs. I'm not a big fan of data bags (this
cookbook was initially created for chef-solo) but if you are - you can
quite
easily alter it to use data bags instead of attributes.

I had a look at rails_ghetto some time ago and I like it. If anything,
it shows a big benefit of the "new" application cookbook: you were
able to reuse its LWRPs to add functionality on top.

One question though: how come you rolled your own nginx_sites_enable
instead of using application_nginx? Any missing functionality there?
At a cursory glance it looks like a perfect match, you just need to
specify your own template.
I.e. in your recipes/deploy.rb:

rails_applications do |name, app|
application name do

nginx do
template "nginx_site.erb"
cookbook_name "rails_ghetto"
end
end
end

And you'd be pretty much set.

Did you try that and hit any roadblock?

Andrea

Furthermore these error messages have been improved in 10.14.0. I'd
highly recommend you upgrade.

Regards,

AJ

On 10 September 2012 18:18, AJ Christensen aj@junglist.gen.nz wrote:

On 10 September 2012 18:13, Marcelo de Moraes Serpa celoserpa@gmail.com wrote:

Igor,

I've been trying to get rails_ghetto up and running in a test Vagrant VM,
but I'm having a hard time - mainly because I'm still quite new to all those
chef[solo] concepts, I'd say. If you could give me a hand, I'd be really
grateful. Here's the portion of my Vagrantfile that sets up the chef-solo
integration:

config.vm.provision :chef_solo do |chef|
chef.cookbooks_path =
"/Users/fullofcaffeine/workspace/code/chef-repo/cookbooks"
chef.roles_path =
"/Users/fullofcaffeine/workspace/code/chef-repo/roles"
chef.data_bags_path =
"/Users/fullofcaffeine/workspace/code/chef-repo/data_bags"
#run list
chef.add_recipe("rails_ghetto::user")
chef.add_recipe("rails_ghetto::deploy")
chef.add_recipe("rails_ghetto::nginx_sites_enable")

#chef.add_recipe("php")
chef.json = { "rails_ghetto" => {
"deployment_user" => "deploy",
 "deployment_group" => "deploy",
 "apps_root" => "/var/www/apps",
 "libs" => ["libxslt-dev","libxml2-dev"],
 "applications" => {"sample" => {
      "repository" => "git@github.com:fullofcaffeine/raks.git",
      "revision" => "master",
      "deploy_key" => "/home/root/.ssh/github",
      "unicorn_port" => "8080",
      "server_name" => "production.example.com",
      "compile_assets" => "true",
      "run_migrations" => "true",
      "rails_environment" => "production",
       "database" => { "adapter" => "postgresql",
                       "database" => "sample2",
                       "username" => "root",
                       "password" => "changeit" },
       }
      },
     "recipes" =>

["rails_ghetto::user","rails_ghetto::deploy","rails_ghetto::nginx_sites_enable"]
}
}

end

There are some fields that I need to change, but I wanted to let it run
first and then start the trial and error. However, it just fails with a
message that I can't interpet (tried googling but didn't find anything
useful). Here's the stacktrace:

Generated at Mon Sep 10 06:03:34 +0000 2012
NameError: Cannot find a resource for application on ubuntu version 12.04

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/resource_platform_map.rb:129:in
`get'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/resource.rb:667:in
`resource_for_platform'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/resource.rb:684:in
`resource_for_node'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/mixin/recipe_definition_dsl_core.rb:58:in
`method_missing'

/tmp/vagrant-chef-1/chef-solo-1/cookbooks/rails_ghetto/recipes/deploy.rb:9:in
`from_file'

Looks like this recipe here ^ is calling an "application" local ivar
or resource which doesn't exist, on line 9.

HTH

--AJ

/tmp/vagrant-chef-1/chef-solo-1/cookbooks/rails_ghetto/libraries/default.rb:7:in
`call'

/tmp/vagrant-chef-1/chef-solo-1/cookbooks/rails_ghetto/libraries/default.rb:7:in
`rails_applications'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/node/attribute.rb:136:in
`call'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/node/attribute.rb:136:in
`each'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/node/attribute.rb:129:in
`each'

/tmp/vagrant-chef-1/chef-solo-1/cookbooks/rails_ghetto/libraries/default.rb:4:in
`rails_applications'

/tmp/vagrant-chef-1/chef-solo-1/cookbooks/rails_ghetto/recipes/deploy.rb:8:in
`from_file'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/cookbook_version.rb:578:in
`load_recipe'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/mixin/language_include_recipe.rb:46:in
`load_recipe'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/mixin/language_include_recipe.rb:33:in
`include_recipe'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/mixin/language_include_recipe.rb:27:in
`each'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/mixin/language_include_recipe.rb:27:in
`include_recipe'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/run_context.rb:72:in
`load'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/run_context.rb:69:in
`each'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/run_context.rb:69:in
`load'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/client.rb:199:in
`setup_run_context'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/client.rb:162:in
`run'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/application/solo.rb:207:in
`run_application'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/application/solo.rb:195:in
`loop'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/application/solo.rb:195:in
`run_application'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/application.rb:70:in
run' /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/chef-solo:25 /opt/vagrant_ruby/bin/chef-solo:19:in load'
/opt/vagrant_ruby/bin/chef-solo:19

Any ideas?

Thanks in advance!

  • Marcelo.

On Thu, Aug 16, 2012 at 8:56 PM, Marcelo de Moraes Serpa
celoserpa@gmail.com wrote:

Wow! Thanks for the comprehensive reply Andrea!

I'll try those suggestion tonight. @Igor, I'll check out rails_ghetto as
well! I'll share my experience here afterwards.

Meanwhile, I have a quick question regarding the approach of Bryan
Baugher, in this thread:

chef - [chef] RE: Re: Multiple application instances on a node

How would that work?

Thank you very much again for the replies!

  • Marcelo.

On Thu, Aug 16, 2012 at 5:22 AM, Igor Afonov afonov@gmail.com wrote:

Andrea,

Wow, thanks, I've totally missed that I can do it like that. I thought
that there maybe a better way to do it but totally missed most obvious way.

Igor

Отправлено при помощи Sparrow

четверг, 16 августа 2012 г. в 11:38, Andrea Campi написал:

Igor,

On Thu, Aug 16, 2012 at 9:36 AM, Igor Afonov afonov@gmail.com wrote:

Hi Marcelo,

I've already mentioned in this list but I have a cookbook which is
basically
what you need. It manages deployment of several very similar rails
applications. As Andrea mentioned if you have different applications it
is
better to have a separate cookbooks for them. But for your case here is
the
cookbook - GitHub - iafonov/rails_ghetto: Chef cookbook intended for managing & deployment of multiple rack-based applications living on one server behind nginx. Supports asset pipeline right from the box.. I'm 100% sure that
you'd
have to change it for your needs. I'm not a big fan of data bags (this
cookbook was initially created for chef-solo) but if you are - you can
quite
easily alter it to use data bags instead of attributes.

I had a look at rails_ghetto some time ago and I like it. If anything,
it shows a big benefit of the "new" application cookbook: you were
able to reuse its LWRPs to add functionality on top.

One question though: how come you rolled your own nginx_sites_enable
instead of using application_nginx? Any missing functionality there?
At a cursory glance it looks like a perfect match, you just need to
specify your own template.
I.e. in your recipes/deploy.rb:

rails_applications do |name, app|
application name do

nginx do
template "nginx_site.erb"
cookbook_name "rails_ghetto"
end
end
end

And you'd be pretty much set.

Did you try that and hit any roadblock?

Andrea

AJ, thanks for the reply,

My mistake, I forgot to clone the additional cookbooks required by
rails_ghetto. To solve it, I just cloned the three dependencies
(application, nginx and application_rupy) into my cookbooks directory and
reloaded the virtual machine. I'm now getting another error, but it's
related to how the rails_ghetto recipe is setup.

Thanks!

  • Marcelo.

On Mon, Sep 10, 2012 at 1:19 AM, AJ Christensen aj@junglist.gen.nz wrote:

Furthermore these error messages have been improved in 10.14.0. I'd
highly recommend you upgrade.

Regards,

AJ

On 10 September 2012 18:18, AJ Christensen aj@junglist.gen.nz wrote:

On 10 September 2012 18:13, Marcelo de Moraes Serpa celoserpa@gmail.com
wrote:

Igor,

I've been trying to get rails_ghetto up and running in a test Vagrant
VM,
but I'm having a hard time - mainly because I'm still quite new to all
those
chef[solo] concepts, I'd say. If you could give me a hand, I'd be really
grateful. Here's the portion of my Vagrantfile that sets up the
chef-solo
integration:

config.vm.provision :chef_solo do |chef|
chef.cookbooks_path =
"/Users/fullofcaffeine/workspace/code/chef-repo/cookbooks"
chef.roles_path =
"/Users/fullofcaffeine/workspace/code/chef-repo/roles"
chef.data_bags_path =
"/Users/fullofcaffeine/workspace/code/chef-repo/data_bags"
#run list
chef.add_recipe("rails_ghetto::user")
chef.add_recipe("rails_ghetto::deploy")
chef.add_recipe("rails_ghetto::nginx_sites_enable")

#chef.add_recipe("php")
chef.json = { "rails_ghetto" => {
"deployment_user" => "deploy",
 "deployment_group" => "deploy",
 "apps_root" => "/var/www/apps",
 "libs" => ["libxslt-dev","libxml2-dev"],
 "applications" => {"sample" => {
      "repository" => "git@github.com:fullofcaffeine/raks.git",
      "revision" => "master",
      "deploy_key" => "/home/root/.ssh/github",
      "unicorn_port" => "8080",
      "server_name" => "production.example.com",
      "compile_assets" => "true",
      "run_migrations" => "true",
      "rails_environment" => "production",
       "database" => { "adapter" => "postgresql",
                       "database" => "sample2",
                       "username" => "root",
                       "password" => "changeit" },
       }
      },
     "recipes" =>

["rails_ghetto::user","rails_ghetto::deploy","rails_ghetto::nginx_sites_enable"]

   }
}

end

There are some fields that I need to change, but I wanted to let it run
first and then start the trial and error. However, it just fails with a
message that I can't interpet (tried googling but didn't find anything
useful). Here's the stacktrace:

Generated at Mon Sep 10 06:03:34 +0000 2012
NameError: Cannot find a resource for application on ubuntu version
12.04

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/resource_platform_map.rb:129:in

`get'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/resource.rb:667:in

`resource_for_platform'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/resource.rb:684:in

`resource_for_node'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/mixin/recipe_definition_dsl_core.rb:58:in

`method_missing'

/tmp/vagrant-chef-1/chef-solo-1/cookbooks/rails_ghetto/recipes/deploy.rb:9:in

`from_file'

Looks like this recipe here ^ is calling an "application" local ivar
or resource which doesn't exist, on line 9.

HTH

--AJ

/tmp/vagrant-chef-1/chef-solo-1/cookbooks/rails_ghetto/libraries/default.rb:7:in

`call'

/tmp/vagrant-chef-1/chef-solo-1/cookbooks/rails_ghetto/libraries/default.rb:7:in

`rails_applications'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/node/attribute.rb:136:in

`call'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/node/attribute.rb:136:in

`each'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/node/attribute.rb:129:in

`each'

/tmp/vagrant-chef-1/chef-solo-1/cookbooks/rails_ghetto/libraries/default.rb:4:in

`rails_applications'

/tmp/vagrant-chef-1/chef-solo-1/cookbooks/rails_ghetto/recipes/deploy.rb:8:in

`from_file'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/cookbook_version.rb:578:in

`load_recipe'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/mixin/language_include_recipe.rb:46:in

`load_recipe'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/mixin/language_include_recipe.rb:33:in

`include_recipe'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/mixin/language_include_recipe.rb:27:in

`each'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/mixin/language_include_recipe.rb:27:in

`include_recipe'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/run_context.rb:72:in

`load'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/run_context.rb:69:in

`each'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/run_context.rb:69:in

`load'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/client.rb:199:in

`setup_run_context'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/client.rb:162:in

`run'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/application/solo.rb:207:in

`run_application'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/application/solo.rb:195:in

`loop'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/application/solo.rb:195:in

`run_application'

/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/application.rb:70:in

run' /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/chef-solo:25 /opt/vagrant_ruby/bin/chef-solo:19:in load'
/opt/vagrant_ruby/bin/chef-solo:19

Any ideas?

Thanks in advance!

  • Marcelo.

On Thu, Aug 16, 2012 at 8:56 PM, Marcelo de Moraes Serpa
celoserpa@gmail.com wrote:

Wow! Thanks for the comprehensive reply Andrea!

I'll try those suggestion tonight. @Igor, I'll check out rails_ghetto
as
well! I'll share my experience here afterwards.

Meanwhile, I have a quick question regarding the approach of Bryan
Baugher, in this thread:

chef - [chef] RE: Re: Multiple application instances on a node

How would that work?

Thank you very much again for the replies!

  • Marcelo.

On Thu, Aug 16, 2012 at 5:22 AM, Igor Afonov afonov@gmail.com wrote:

Andrea,

Wow, thanks, I've totally missed that I can do it like that. I thought
that there maybe a better way to do it but totally missed most
obvious way.

Igor

Отправлено при помощи Sparrow

четверг, 16 августа 2012 г. в 11:38, Andrea Campi написал:

Igor,

On Thu, Aug 16, 2012 at 9:36 AM, Igor Afonov afonov@gmail.com
wrote:

Hi Marcelo,

I've already mentioned in this list but I have a cookbook which is
basically
what you need. It manages deployment of several very similar rails
applications. As Andrea mentioned if you have different applications
it
is
better to have a separate cookbooks for them. But for your case here
is
the
cookbook - GitHub - iafonov/rails_ghetto: Chef cookbook intended for managing & deployment of multiple rack-based applications living on one server behind nginx. Supports asset pipeline right from the box.. I'm 100% sure
that
you'd
have to change it for your needs. I'm not a big fan of data bags (this
cookbook was initially created for chef-solo) but if you are - you can
quite
easily alter it to use data bags instead of attributes.

I had a look at rails_ghetto some time ago and I like it. If anything,
it shows a big benefit of the "new" application cookbook: you were
able to reuse its LWRPs to add functionality on top.

One question though: how come you rolled your own nginx_sites_enable
instead of using application_nginx? Any missing functionality there?
At a cursory glance it looks like a perfect match, you just need to
specify your own template.
I.e. in your recipes/deploy.rb:

rails_applications do |name, app|
application name do
...
nginx do
template "nginx_site.erb"
cookbook_name "rails_ghetto"
end
end
end

And you'd be pretty much set.

Did you try that and hit any roadblock?

Andrea