Running two applications in the same node using application cookbook

Is it possible to run 2 applications in the same node using the application
cookbook?

I have tried to do it by adding two roles of two different applications to
the same node. Both roles are based on the application cookbook.

But just one of the applications is being installed.

Do I need to do something special?

Thanks

Daniel Cukier

Hello,

On Apr 25, 2012, at 4:26 PM, Daniel Cukier wrote:

Is it possible to run 2 applications in the same node using the application cookbook?

I have tried to do it by adding two roles of two different applications to the same node. Both roles are based on the application cookbook.

But just one of the applications is being installed.

It is not currently possible because of the way the application::default recipe works and how Chef de-duplicates recipes.

The application::default recipe does an "include_recipe" for each recipe relevant to the application being managed, so if you have two apps that should be rails + unicorn, it does this:

# app1
include_recipe "application::rails"
include_recipe "application::unicorn"

# app2
include_recipe "application::rails"
include_recipe "application::unicorn"

However, the second app, Chef will say[0] "not including recipe application::rails because I have already seen it.

The solution to this problem is address by implementing "application" as a lightweight resource, and is the work done primarily by Noah and Andrea for COOK-634[1][2]. The cookbooks for this work will be released by Opscode at some point soon; the more people we get testing the code the better, and the sooner we can release. They're probably beta quality right now, though I believe that the existing recipes will remain backwards compatible for a couple months after release.

[0]: you can see the messages with -l debug
[1]: GitHub - andreacampi/application at COOK-634
[2]: chef - [chef] Application cookbook refactoring

--
Opscode, Inc
Joshua Timberman, Technical Program Manager
IRC, Skype, Twitter, Github: jtimberman

I'd also the same issue earlier. But I've fixed it by modifying some code and restructuring the data_bag and the database master recipe.
And now I can deploy not only multiple rails + unicorn app, but also PHP apps like Drupal and Wordpress on the same node.

I'll be doing a screencast soon as I've seen this pain with other devs too.


@millisami
~ Sachin Sagar Rai
Ruby on Rails Developer
http://tfm.com.np
http://nepalonrails.tumblr.com
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)

On Thursday, April 26, 2012 at 9:06 PM, Joshua Timberman wrote:

Hello,

On Apr 25, 2012, at 4:26 PM, Daniel Cukier wrote:

Is it possible to run 2 applications in the same node using the application cookbook?

I have tried to do it by adding two roles of two different applications to the same node. Both roles are based on the application cookbook.

But just one of the applications is being installed.

It is not currently possible because of the way the application::default recipe works and how Chef de-duplicates recipes.

The application::default recipe does an "include_recipe" for each recipe relevant to the application being managed, so if you have two apps that should be rails + unicorn, it does this:

app1

include_recipe "application::rails"
include_recipe "application::unicorn"

app2

include_recipe "application::rails"
include_recipe "application::unicorn"

However, the second app, Chef will say[0] "not including recipe application::rails because I have already seen it.

The solution to this problem is address by implementing "application" as a lightweight resource, and is the work done primarily by Noah and Andrea for COOK-634[1][2]. The cookbooks for this work will be released by Opscode at some point soon; the more people we get testing the code the better, and the sooner we can release. They're probably beta quality right now, though I believe that the existing recipes will remain backwards compatible for a couple months after release.

[0]: you can see the messages with -l debug
[1]: GitHub - andreacampi/application at COOK-634
[2]: chef - [chef] Application cookbook refactoring

--
Opscode, Inc
Joshua Timberman, Technical Program Manager
IRC, Skype, Twitter, Github: jtimberman

I did a dirty hack right in the application::default recipe. it works. But
I agree this solution smells :slight_smile:

  node.run_state[:current_app] = app


  node.run_state[:seen_recipes].delete("application::#{recipe}")


  include_recipe "application::#{recipe}"

--max

On Thu, Apr 26, 2012 at 11:23 AM, Sachin Sagar Rai millisami@gmail.comwrote:

I'd also the same issue earlier. But I've fixed it by modifying some code
and restructuring the data_bag and the database master recipe.
And now I can deploy not only multiple rails + unicorn app, but also PHP
apps like Drupal and Wordpress on the same node.

I'll be doing a screencast soon as I've seen this pain with other devs too.


@millisami
~ Sachin Sagar Rai
Ruby on Rails Developer
http://tfm.com.np
http://nepalonrails.tumblr.com
Sent with Sparrow http://www.sparrowmailapp.com/?sig

On Thursday, April 26, 2012 at 9:06 PM, Joshua Timberman wrote:

Hello,

On Apr 25, 2012, at 4:26 PM, Daniel Cukier wrote:

Is it possible to run 2 applications in the same node using the
application cookbook?

I have tried to do it by adding two roles of two different applications to
the same node. Both roles are based on the application cookbook.

But just one of the applications is being installed.

It is not currently possible because of the way the application::default
recipe works and how Chef de-duplicates recipes.

The application::default recipe does an "include_recipe" for each recipe
relevant to the application being managed, so if you have two apps that
should be rails + unicorn, it does this:

app1

include_recipe "application::rails"
include_recipe "application::unicorn"

app2

include_recipe "application::rails"
include_recipe "application::unicorn"

However, the second app, Chef will say[0] "not including recipe
application::rails because I have already seen it.

The solution to this problem is address by implementing "application" as a
lightweight resource, and is the work done primarily by Noah and Andrea for
COOK-634[1][2]. The cookbooks for this work will be released by Opscode at
some point soon; the more people we get testing the code the better, and
the sooner we can release. They're probably beta quality right now, though
I believe that the existing recipes will remain backwards compatible for a
couple months after release.

[0]: you can see the messages with -l debug
[1]: GitHub - andreacampi/application at COOK-634
[2]: chef - [chef] Application cookbook refactoring

--
Opscode, Inc
Joshua Timberman, Technical Program Manager
IRC, Skype, Twitter, Github: jtimberman