Including multiple time the same recipe with different attribute

Hi,

I’m trying to deploy multiple java applications with the java wrapper
cookbook. What the java wrapper does is:

  • download the java wrapper, unpack it
  • copy files to a specified directory
  • create a service and start it.
    what it needs is:
  • the name of the the service and the place where to find the jars.

The java-wrapper works for a single application (I’ve shared the cookbook
on the site).
What I was planning to do was, for each application do something like:

  • recipe A:
    override[java-wrapper][name] = a
    include_recipe “java_wrapper”
  • recipe B:
    override[java-wrapper][name] = b
    include_recipe “java_wrapper”

hoping that the java_wrapper recipe would be called once with a attribute
and once again with b attribute. But what is happening is that the
"java_wrapper" recipe is run only once. After re-reading chef
documentation, I’m not even sure the attribute java-wrapper/name can have
value a and then b during a chef-client run.

What would be a good way to solve the original problem ?

Alex

You can expose the work that the java_wrapper recipe does as an LWRP:
http://docs.opscode.com/lwrp_custom.html. Another option might be using
the application_java cookbook, assuming it does things the way you need it.

Greg

On 10/23/13 07:48, Alexandre Russel wrote:

Hi,

I'm trying to deploy multiple java applications with the java wrapper
cookbook. What the java wrapper does is:

  • download the java wrapper, unpack it
  • copy files to a specified directory
  • create a service and start it.
    what it needs is:
  • the name of the the service and the place where to find the jars.

The java-wrapper works for a single application (I've shared the
cookbook on the site).
What I was planning to do was, for each application do something like:

  • recipe A:
    override[java-wrapper][name] = a
    include_recipe "java_wrapper"
  • recipe B:
    override[java-wrapper][name] = b
    include_recipe "java_wrapper"

hoping that the java_wrapper recipe would be called once with a
attribute and once again with b attribute. But what is happening is
that the "java_wrapper" recipe is run only once. After re-reading chef
documentation, I'm not even sure the attribute java-wrapper/name can
have value a and then b during a chef-client run.

What would be a good way to solve the original problem ?

Alex

thanks Greg for your answer, can a LWRP do the same as recipe ? I need to
download the java-wrapper zip file only once, and then copy it for each of
the cookbook that would need it. Where is the 'normal' place to put it so I
can check if it is there and don't re-fetch ?

On Wed, Oct 23, 2013 at 4:21 PM, Greg Symons gsymons@drillinginfo.comwrote:

You can expose the work that the java_wrapper recipe does as an LWRP:
http://docs.opscode.com/lwrp_custom.html. Another option might be using
the application_java cookbook, assuming it does things the way you need it.

Greg

On 10/23/13 07:48, Alexandre Russel wrote:

Hi,

I'm trying to deploy multiple java applications with the java wrapper
cookbook. What the java wrapper does is:

  • download the java wrapper, unpack it
  • copy files to a specified directory
  • create a service and start it.
    what it needs is:
  • the name of the the service and the place where to find the jars.

The java-wrapper works for a single application (I've shared the
cookbook on the site).
What I was planning to do was, for each application do something like:

  • recipe A:
    override[java-wrapper][name] = a
    include_recipe "java_wrapper"
  • recipe B:
    override[java-wrapper][name] = b
    include_recipe "java_wrapper"

hoping that the java_wrapper recipe would be called once with a
attribute and once again with b attribute. But what is happening is that
the "java_wrapper" recipe is run only once. After re-reading chef
documentation, I'm not even sure the attribute java-wrapper/name can have
value a and then b during a chef-client run.

What would be a good way to solve the original problem ?

Alex

Pretty much every thing , except include_recipe
On Oct 23, 2013 10:40 AM, "Alexandre Russel" alexandre@russel.fr wrote:

thanks Greg for your answer, can a LWRP do the same as recipe ? I need to
download the java-wrapper zip file only once, and then copy it for each of
the cookbook that would need it. Where is the 'normal' place to put it so I
can check if it is there and don't re-fetch ?

On Wed, Oct 23, 2013 at 4:21 PM, Greg Symons gsymons@drillinginfo.comwrote:

You can expose the work that the java_wrapper recipe does as an LWRP:
http://docs.opscode.com/lwrp_custom.html. Another option might be using
the application_java cookbook, assuming it does things the way you need it.

Greg

On 10/23/13 07:48, Alexandre Russel wrote:

Hi,

I'm trying to deploy multiple java applications with the java wrapper
cookbook. What the java wrapper does is:

  • download the java wrapper, unpack it
  • copy files to a specified directory
  • create a service and start it.
    what it needs is:
  • the name of the the service and the place where to find the jars.

The java-wrapper works for a single application (I've shared the
cookbook on the site).
What I was planning to do was, for each application do something like:

  • recipe A:
    override[java-wrapper][name] = a
    include_recipe "java_wrapper"
  • recipe B:
    override[java-wrapper][name] = b
    include_recipe "java_wrapper"

hoping that the java_wrapper recipe would be called once with a
attribute and once again with b attribute. But what is happening is that
the "java_wrapper" recipe is run only once. After re-reading chef
documentation, I'm not even sure the attribute java-wrapper/name can have
value a and then b during a chef-client run.

What would be a good way to solve the original problem ?

Alex

Actually, it can even do that... you just have to access the run_context
to do it.

Greg

On 10/23/13 12:42, Ranjib Dey wrote:

Pretty much every thing , except include_recipe

On Oct 23, 2013 10:40 AM, "Alexandre Russel" <alexandre@russel.fr
mailto:alexandre@russel.fr> wrote:

thanks Greg for your answer, can a LWRP do the same as recipe ? I
need to download the java-wrapper zip file only once, and then
copy it for each of the cookbook that would need it. Where is the
'normal' place to put it so I can check if it is there and don't
re-fetch ?


On Wed, Oct 23, 2013 at 4:21 PM, Greg Symons
<gsymons@drillinginfo.com <mailto:gsymons@drillinginfo.com>> wrote:

    You can expose the work that the java_wrapper recipe does as
    an LWRP: http://docs.opscode.com/lwrp_custom.html. Another
    option might be using the application_java cookbook, assuming
    it does things the way you need it.

    Greg


    On 10/23/13 07:48, Alexandre Russel wrote:
    Hi,

     I'm trying to deploy multiple java applications with the
    java wrapper cookbook. What the java wrapper does is:
    - download the java wrapper, unpack it
    - copy files to a specified directory
     - create a service and start it.
    what it needs is:
    - the name of the the service and the place where to find the
    jars.


    The java-wrapper works for a single application (I've shared
    the cookbook on the site).
    What I was planning to do was, for each application do
    something like:
    - recipe A:
      override[java-wrapper][name] = a
      include_recipe "java_wrapper"
    - recipe B:
      override[java-wrapper][name] = b
      include_recipe "java_wrapper"

    hoping that the java_wrapper  recipe would be called once
    with a attribute and once again with b attribute. But what is
    happening is that the "java_wrapper" recipe is run only once.
    After re-reading chef documentation, I'm not even sure the
    attribute java-wrapper/name can have value a and then b
    during a chef-client run.

    What would be a good way to solve the original problem ?

    Alex

i would love to see some snippets :slight_smile: . this is tricky, as now you have to
do whole cookbook dependency resolution, and compiling them, which iirc can
not be done during the convergence phase.

On Wed, Oct 23, 2013 at 11:14 AM, Greg Symons gsymons@drillinginfo.comwrote:

Actually, it can even do that... you just have to access the run_context
to do it.

Greg

On 10/23/13 12:42, Ranjib Dey wrote:

Pretty much every thing , except include_recipe
On Oct 23, 2013 10:40 AM, "Alexandre Russel" alexandre@russel.fr wrote:

thanks Greg for your answer, can a LWRP do the same as recipe ? I need to
download the java-wrapper zip file only once, and then copy it for each of
the cookbook that would need it. Where is the 'normal' place to put it so I
can check if it is there and don't re-fetch ?

On Wed, Oct 23, 2013 at 4:21 PM, Greg Symons gsymons@drillinginfo.comwrote:

You can expose the work that the java_wrapper recipe does as an LWRP:
http://docs.opscode.com/lwrp_custom.html. Another option might be using
the application_java cookbook, assuming it does things the way you need it.

Greg

On 10/23/13 07:48, Alexandre Russel wrote:

Hi,

I'm trying to deploy multiple java applications with the java wrapper
cookbook. What the java wrapper does is:

  • download the java wrapper, unpack it
  • copy files to a specified directory
  • create a service and start it.
    what it needs is:
  • the name of the the service and the place where to find the jars.

The java-wrapper works for a single application (I've shared the
cookbook on the site).
What I was planning to do was, for each application do something like:

  • recipe A:
    override[java-wrapper][name] = a
    include_recipe "java_wrapper"
  • recipe B:
    override[java-wrapper][name] = b
    include_recipe "java_wrapper"

hoping that the java_wrapper recipe would be called once with a
attribute and once again with b attribute. But what is happening is that
the "java_wrapper" recipe is run only once. After re-reading chef
documentation, I'm not even sure the attribute java-wrapper/name can have
value a and then b during a chef-client run.

What would be a good way to solve the original problem ?

Alex