[chef] Re: Re: Re: Re: Re: Re: Configure/deploy multiples apps per cookbook, how?


Chronological Thread 
  • From: AJ Christensen < >
  • To:
  • Subject: [chef] Re: Re: Re: Re: Re: Re: Configure/deploy multiples apps per cookbook, how?
  • Date: Mon, 10 Sep 2012 18:18:55 +1200

On 10 September 2012 18:13, Marcelo de Moraes Serpa 
< >
 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" => 
>> " :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
> < >
>  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:
>>
>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 
>> < >
>>  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 
>>> < >
>>>  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 - https://github.com/iafonov/rails_ghetto. 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
>>>
>>>
>>
>



Archive powered by MHonArc 2.6.16.

§