Application Cookbook

Hi *,

I want to leverage the application cookbook for installing multiple applications of the same type.
So I thought I re-use e.g. the application::java_webapp recipe. But this obviously (or not so obviously)
does not work the way I thought it should.

Problem is:

search(:apps) do |app|
(app[“server_roles”] & node.run_list.roles).each do |app_role|

app["type"][app_role].each do |thing|
  node.run_state[:current_app] = app
  include_recipe "application::#{thing}"
end

end
end

Does the loop correctly, BUT include_recipe will only work for the first application of a type (which is by design)

[Thu, 21 Apr 2011 01:15:22 -0700] DEBUG: I am not loading application::java_webapp, because I have already seen it.
[Thu, 21 Apr 2011 01:15:22 -0700] DEBUG: I am not loading application::java_webapp, because I have already seen it.
[Thu, 21 Apr 2011 01:15:22 -0700] DEBUG: I am not loading application::java_webapp, because I have already seen it.

So what to do instead?

  1. Use a definition for DRY? But that is depricated, but somehow would feel correct?
  2. Use LWRP just to reuse the code from java_webapp.
  3. Patch chef itself to allow a “force_include”
  4. just copy the code to distinct recipes. But that’s not DRY

any thoughts?

cu edi

DI Edmund Haselwanter, edmund@haselwanter.com, http://edmund.haselwanter.com/
http://www.iteh.at | http://facebook.com/iTeh.solutions | http://at.linkedin.com/in/haselwanteredmund

On 21.04.2011, at 10:26, Haselwanter Edmund wrote:

Hi *,

I want to leverage the application cookbook for installing multiple applications of the same type.
So I thought I re-use e.g. the application::java_webapp recipe. But this obviously (or not so obviously)
does not work the way I thought it should.

Problem is:

search(:apps) do |app|
(app["server_roles"] & node.run_list.roles).each do |app_role|

app["type"][app_role].each do |thing|
node.run_state[:current_app] = app
include_recipe "application::#{thing}"
end
end
end

search(:apps) do |app|
(app["server_roles"] & node.roles).each do |app_role|

app["type"][app_role].each do |thing|
  node.run_state[:current_app] = app
  include_recipe "application::#{thing}"
end
app["type"]["#{app_role}_definitions"].each do |thing|
  node.run_state[:current_app] = app
  eval %Q{#{thing} "#{app['id']}-#{thing}"}
end

end
end

Does the loop correctly, BUT include_recipe will only work for the first application of a type (which is by design)

[Thu, 21 Apr 2011 01:15:22 -0700] DEBUG: I am not loading application::java_webapp, because I have already seen it.
[Thu, 21 Apr 2011 01:15:22 -0700] DEBUG: I am not loading application::java_webapp, because I have already seen it.
[Thu, 21 Apr 2011 01:15:22 -0700] DEBUG: I am not loading application::java_webapp, because I have already seen it.

So what to do instead?

  1. Use a definition for DRY? But that is depricated, but somehow would feel correct?

Hm. Where did I get that definitions are deprecated? Anyway. Putting the stuff of reusable parts of the application cookbooks into
"resource groupings" aka definitions does work.

  1. Use LWRP just to reuse the code from java_webapp.
  2. Patch chef itself to allow a "force_include"
  3. just copy the code to distinct recipes. But that's not DRY

any thoughts?

cu edi

DI Edmund Haselwanter, edmund@haselwanter.com, http://edmund.haselwanter.com/
http://www.iteh.at | Facebook | http://at.linkedin.com/in/haselwanteredmund

--
DI Edmund Haselwanter, edmund@haselwanter.com, http://edmund.haselwanter.com/
http://www.iteh.at | Facebook | http://at.linkedin.com/in/haselwanteredmund

Edmund,
This is a know issue. The plan is to refactor the application cookbook's recipes into a series of LWRPs which will allow multiple applications (of the same type) to be deployed on the same server. This will also allow the deploy (and server daemon config) logic to be leveraged from outside of the application cookbook.

Seth

--
Opscode, Inc.
Seth Chisamore, Senior Technical Evangelist
IRC, Skype, Twitter, Github: schisamo

On Thursday, April 21, 2011 at 5:10 AM, Haselwanter Edmund wrote:

On 21.04.2011, at 10:26, Haselwanter Edmund wrote:

Hi *,

I want to leverage the application cookbook for installing multiple applications of the same type.
So I thought I re-use e.g. the application::java_webapp recipe. But this obviously (or not so obviously)
does not work the way I thought it should.

Problem is:

search(:apps) do |app|
(app["server_roles"] & node.run_list.roles).each do |app_role|

app["type"][app_role].each do |thing|
node.run_state[:current_app] = app
include_recipe "application::#{thing}"
end
end
end

search(:apps) do |app|
(app["server_roles"] & node.roles).each do |app_role|

app["type"][app_role].each do |thing|
node.run_state[:current_app] = app
include_recipe "application::#{thing}"
end
app["type"]["#{app_role}_definitions"].each do |thing|
node.run_state[:current_app] = app
eval %Q{#{thing} "#{app['id']}-#{thing}"}
end

end
end

Does the loop correctly, BUT include_recipe will only work for the first application of a type (which is by design)

[Thu, 21 Apr 2011 01:15:22 -0700] DEBUG: I am not loading application::java_webapp, because I have already seen it.
[Thu, 21 Apr 2011 01:15:22 -0700] DEBUG: I am not loading application::java_webapp, because I have already seen it.
[Thu, 21 Apr 2011 01:15:22 -0700] DEBUG: I am not loading application::java_webapp, because I have already seen it.

So what to do instead?

  1. Use a definition for DRY? But that is depricated, but somehow would feel correct?

Hm. Where did I get that definitions are deprecated? Anyway. Putting the stuff of reusable parts of the application cookbooks into
"resource groupings" aka definitions does work.

  1. Use LWRP just to reuse the code from java_webapp.
  2. Patch chef itself to allow a "force_include"
  3. just copy the code to distinct recipes. But that's not DRY

any thoughts?

cu edi

DI Edmund Haselwanter, edmund@haselwanter.com, http://edmund.haselwanter.com/
http://www.iteh.at | Facebook | http://at.linkedin.com/in/haselwanteredmund

--
DI Edmund Haselwanter, edmund@haselwanter.com, http://edmund.haselwanter.com/
http://www.iteh.at | Facebook | http://at.linkedin.com/in/haselwanteredmund

Hi Seth

On 21.04.2011, at 13:27, Seth Chisamore wrote:

Edmund,
This is a know issue. The plan is to refactor the application cookbook's recipes into a series of LWRPs which will allow multiple applications (of the same type) to be deployed on the same server.

Do you have a draft of this work in progress?

This will also allow the deploy (and server daemon config) logic to be leveraged from outside of the application cookbook.

I have refactored my heavy tomcat6 manager provider into a TomcatContext LWRP which leverages the tomcat (opscode) cookbook and tomcat manager application. It "works" but might need some polish. and would it would need access to the node for defaults (http://tickets.opscode.com/browse/CHEF-1946 which I don't think is in the current release ?)

cu edi

Seth

--
Opscode, Inc.
Seth Chisamore, Senior Technical Evangelist
IRC, Skype, Twitter, Github: schisamo

On Thursday, April 21, 2011 at 5:10 AM, Haselwanter Edmund wrote:

On 21.04.2011, at 10:26, Haselwanter Edmund wrote:

Hi *,

I want to leverage the application cookbook for installing multiple applications of the same type.
So I thought I re-use e.g. the application::java_webapp recipe. But this obviously (or not so obviously)
does not work the way I thought it should.

Problem is:

search(:apps) do |app|
(app["server_roles"] & node.run_list.roles).each do |app_role|

app["type"][app_role].each do |thing|
node.run_state[:current_app] = app
include_recipe "application::#{thing}"
end
end
end

search(:apps) do |app|
(app["server_roles"] & node.roles).each do |app_role|

app["type"][app_role].each do |thing|
node.run_state[:current_app] = app
include_recipe "application::#{thing}"
end
app["type"]["#{app_role}_definitions"].each do |thing|
node.run_state[:current_app] = app
eval %Q{#{thing} "#{app['id']}-#{thing}"}
end

end
end

Does the loop correctly, BUT include_recipe will only work for the first application of a type (which is by design)

[Thu, 21 Apr 2011 01:15:22 -0700] DEBUG: I am not loading application::java_webapp, because I have already seen it.
[Thu, 21 Apr 2011 01:15:22 -0700] DEBUG: I am not loading application::java_webapp, because I have already seen it.
[Thu, 21 Apr 2011 01:15:22 -0700] DEBUG: I am not loading application::java_webapp, because I have already seen it.

So what to do instead?

  1. Use a definition for DRY? But that is depricated, but somehow would feel correct?

Hm. Where did I get that definitions are deprecated? Anyway. Putting the stuff of reusable parts of the application cookbooks into
"resource groupings" aka definitions does work.

  1. Use LWRP just to reuse the code from java_webapp.
  2. Patch chef itself to allow a "force_include"
  3. just copy the code to distinct recipes. But that's not DRY

any thoughts?

cu edi

DI Edmund Haselwanter, edmund@haselwanter.com, http://edmund.haselwanter.com/
http://www.iteh.at | Facebook | http://at.linkedin.com/in/haselwanteredmund

--
DI Edmund Haselwanter, edmund@haselwanter.com, http://edmund.haselwanter.com/
http://www.iteh.at | Facebook | http://at.linkedin.com/in/haselwanteredmund

--
DI Edmund Haselwanter, edmund@haselwanter.com, http://edmund.haselwanter.com/
http://www.iteh.at | Facebook | http://at.linkedin.com/in/haselwanteredmund

Hi Edmund,

On Thu, Apr 21, 2011 at 7:39 AM, Haselwanter Edmund
edmund@haselwanter.comwrote:

Hi Seth

On 21.04.2011, at 13:27, Seth Chisamore wrote:

Edmund,
This is a know issue. The plan is to refactor the application cookbook's
recipes into a series of LWRPs which will allow multiple applications (of
the same type) to be deployed on the same server.

Do you have a draft of this work in progress?

Not yet! :slight_smile: The TSE (training, services and evangelism) team (who maintains
the repo) has been busy prepping for the 0.10 release. We have also been
working on CentOS compatibility updates across the repo. I should hopefully
have a first round of these fixes integrated by mid next week.

This will also allow the deploy (and server daemon config) logic to be
leveraged from outside of the application cookbook.

I have refactored my heavy tomcat6 manager provider into a TomcatContext
LWRP which leverages the tomcat (opscode) cookbook and tomcat manager
application. It "works" but might need some polish. and would it would need
access to the node for defaults (
http://tickets.opscode.com/browse/CHEF-1946 which I don't think is in the
current release ?

I'll definitely take a look at your LWRP when we commence on the refactor
and agree CHEF-1946 is going to be VERY helpful.

cu edi

Seth

--
Opscode, Inc.
Seth Chisamore, Senior Technical Evangelist
IRC, Skype, Twitter, Github: schisamo

On Thursday, April 21, 2011 at 5:10 AM, Haselwanter Edmund wrote:

On 21.04.2011, at 10:26, Haselwanter Edmund wrote:

Hi *,

I want to leverage the application cookbook for installing multiple
applications of the same type.
So I thought I re-use e.g. the application::java_webapp recipe. But
this obviously (or not so obviously)
does not work the way I thought it should.

Problem is:

search(:apps) do |app|
(app["server_roles"] & node.run_list.roles).each do |app_role|

app["type"][app_role].each do |thing|
node.run_state[:current_app] = app
include_recipe "application::#{thing}"
end
end
end

search(:apps) do |app|
(app["server_roles"] & node.roles).each do |app_role|

app["type"][app_role].each do |thing|
node.run_state[:current_app] = app
include_recipe "application::#{thing}"
end
app["type"]["#{app_role}_definitions"].each do |thing|
node.run_state[:current_app] = app
eval %Q{#{thing} "#{app['id']}-#{thing}"}
end

end
end

Does the loop correctly, BUT include_recipe will only work for the
first application of a type (which is by design)

[Thu, 21 Apr 2011 01:15:22 -0700] DEBUG: I am not loading
application::java_webapp, because I have already seen it.
[Thu, 21 Apr 2011 01:15:22 -0700] DEBUG: I am not loading
application::java_webapp, because I have already seen it.
[Thu, 21 Apr 2011 01:15:22 -0700] DEBUG: I am not loading
application::java_webapp, because I have already seen it.

So what to do instead?

  1. Use a definition for DRY? But that is depricated, but somehow would
    feel correct?

Hm. Where did I get that definitions are deprecated? Anyway. Putting the
stuff of reusable parts of the application cookbooks into
"resource groupings" aka definitions does work.

  1. Use LWRP just to reuse the code from java_webapp.
  2. Patch chef itself to allow a "force_include"
  3. just copy the code to distinct recipes. But that's not DRY

any thoughts?

cu edi

DI Edmund Haselwanter, edmund@haselwanter.com,
http://edmund.haselwanter.com/
http://www.iteh.at | Facebook |
http://at.linkedin.com/in/haselwanteredmund

--
DI Edmund Haselwanter, edmund@haselwanter.com,
http://edmund.haselwanter.com/
http://www.iteh.at | Facebook |
http://at.linkedin.com/in/haselwanteredmund

--
DI Edmund Haselwanter, edmund@haselwanter.com,
http://edmund.haselwanter.com/
http://www.iteh.at | Facebook |
http://at.linkedin.com/in/haselwanteredmund