Using a template inside a provider

I’m working on a provider for delivering tomcat instances (so separate
CATALINA_BASE/CATALINA_HOME), but I need to deliver customised
versions of some of the standard config files (e.g.
catalina.properties). Trying to use a template inside the provider
works fine, but the recipe consuming the provider then has to know
that it needs that template file inside its template directory.

Is there some way to package templates alongside the provider? Or
maybe I’m going about this the wrong way… I’ll want to be able to
override those file defaults too in different recipes.

Any thoughts?


Alex Kiernan

Alex,
Look into the 'cookbook' attribute for the template resource:
http://wiki.opscode.com/display/chef/Resources#Resources-Template

You can then expose this as an attribute on your LWRP. The default would be set to the cookbook your LWRP lives in. Then pass this value (passed in as an LWRP attribute) directly down to the template resource used in your provider making for easy overrides.

Seth

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

On Wednesday, April 20, 2011 at 7:21 AM, Alex Kiernan wrote:
I'm working on a provider for delivering tomcat instances (so separate

CATALINA_BASE/CATALINA_HOME), but I need to deliver customised
versions of some of the standard config files (e.g.
catalina.properties). Trying to use a template inside the provider
works fine, but the recipe consuming the provider then has to know
that it needs that template file inside its template directory.

Is there some way to package templates alongside the provider? Or
maybe I'm going about this the wrong way... I'll want to be able to
override those file defaults too in different recipes.

Any thoughts?

--
Alex Kiernan

RTFM :slight_smile:

Thanks - for whatever reason the penny just didn't drop that was there
for doing just this!

On 4/20/11, Seth Chisamore schisamo@opscode.com wrote:

Alex,
Look into the 'cookbook' attribute for the template resource:
http://wiki.opscode.com/display/chef/Resources#Resources-Template

You can then expose this as an attribute on your LWRP. The default would be
set to the cookbook your LWRP lives in. Then pass this value (passed in as
an LWRP attribute) directly down to the template resource used in your
provider making for easy overrides.

Seth

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

On Wednesday, April 20, 2011 at 7:21 AM, Alex Kiernan wrote:
I'm working on a provider for delivering tomcat instances (so separate

CATALINA_BASE/CATALINA_HOME), but I need to deliver customised
versions of some of the standard config files (e.g.
catalina.properties). Trying to use a template inside the provider
works fine, but the recipe consuming the provider then has to know
that it needs that template file inside its template directory.

Is there some way to package templates alongside the provider? Or
maybe I'm going about this the wrong way... I'll want to be able to
override those file defaults too in different recipes.

Any thoughts?

--
Alex Kiernan

--
Sent from my mobile device

Alex Kiernan