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


Chronological Thread 
  • From: Igor Afonov < >
  • To:
  • Subject: [chef] Re: Re: Configure/deploy multiples apps per cookbook, how?
  • Date: Thu, 16 Aug 2012 10:36:11 +0300

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.

Thanks,
Igor

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

Hi guys,

Anyone out there? :) 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 < " target="_blank"> > 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/<appname>
   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:


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.







Archive powered by MHonArc 2.6.16.

§