From: Nguyen, Dang
Sent: Thursday, July 16, 2015 8:52 AM
To: 'chef@lists.opscode.com'
Subject: RE: [chef] Append to a template within recipe
You'd want to wrap your base cookbook in the app cookbook. Since you've
already setup the dependency, your next step is to override the template
source being referenced by the template resource. Julian Dunn wrote up a
nice blog, entitled "Doing Wrapper Cookbooks Right" and addresses exactly
how to specify a different template as the source from a wrapper cookbook.
I have a base cookbook and a app cookbook which depends on base.
The base cookbook has a template - base_temp.conf.erb which gets used inside
the app cookbook
app_cookbook/recipe/default.rb has include_recipe 'base'
Is there a way to append to the base template within app cookbook without
modifying the template in the base cookbook as it is applicable only to this
one app.
So can I have a app_temp.conf.erb which gets appended to the base_temp.conf
in the recipe or maybe get the resource collection and append line by line
to the base_temp.conf
I can get the template resource in the app recipe like so
Hi Dang
I did see the article you refer to.
If I am not mistaken , it talks about replacing templates in a wrapper cookbook.
I was wondering, if I can merge the template in base with the template in the wrapper cookbook.
So final output would be
final_conf = base_temp.conf + app_temp.conf
Is template merging possible?
Regards
mg
From: Dang.Nguyen@disney.com
To: chef@lists.opscode.com
Date: Thu, 16 Jul 2015 15:52:27 +0000
Subject: [chef] RE: Append to a template within recipe
Here’s the blog: https://www.chef.io/blog/2013/12/03/doing-wrapper-cookbooks-right/ From: Nguyen, Dang
Sent: Thursday, July 16, 2015 8:52 AM
To: 'chef@lists.opscode.com’
Subject: RE: [chef] Append to a template within recipe You’d want to wrap your base cookbook in the app cookbook. Since you’ve already setup the dependency, your next step is to override the template source being referenced by the template resource. Julian Dunn wrote up a nice blog, entitled “Doing Wrapper Cookbooks Right” and addresses exactly how to specify a different template as the source from a wrapper cookbook. Cheers,Dang Nguyen From: M G [mailto:meher03@hotmail.com]
Sent: Thursday, July 16, 2015 8:41 AM
To: chef@lists.opscode.com
Subject: [chef] Append to a template within recipe Hi I have a base cookbook and a app cookbook which depends on base. The base cookbook has a template - base_temp.conf.erb which gets used inside the app cookbook app_cookbook/recipe/default.rb has include_recipe ‘base’ Is there a way to append to the base template within app cookbook without modifying the template in the base cookbook as it is applicable only to this one app. So can I have a app_temp.conf.erb which gets appended to the base_temp.conf in the recipe or maybe get the resource collection and append line by line to the base_temp.conf I can get the template resource in the app recipe like so run_context.resource_collection.lookup( “template[#{base_template}]”) But I dont know if any of the above is correct. Any pointers would be appreciated? Regards mg
Does your config type support including? Because you could keep the app
portion separate and only include it if a certain attribute is set in the
base template (which would only be set in the app cookbook).
From: Nguyen, Dang Sent: Thursday, July 16, 2015 8:52 AM To: 'chef@lists.opscode.com' Subject: RE: [chef] Append to a template within recipe
You’d want to wrap your base cookbook in the app cookbook. Since you’ve
already setup the dependency, your next step is to override the template
source being referenced by the template resource. Julian Dunn wrote up a
nice blog, entitled “Doing Wrapper Cookbooks Right” and addresses exactly
how to specify a different template as the source from a wrapper cookbook.
I have a base cookbook and a app cookbook which depends on base.
The base cookbook has a template - base_temp.conf.erb which gets used
inside the app cookbook
app_cookbook/recipe/default.rb has include_recipe 'base'
Is there a way to append to the base template within app cookbook without
modifying the template in the base cookbook as it is applicable only to
this one app.
So can I have a app_temp.conf.erb which gets appended to the
base_temp.conf in the recipe or maybe get the resource collection and
append line by line to the base_temp.conf
I can get the template resource in the app recipe like so
Hi Yoshi
Unfortunately, no. Even if it did I cannot modify anything related to base ( due to process/policy/politics/etc)
If I could, then many options would open up .
Thank you for your suggestion.
Regards
mg
Does your config type support including? Because you could keep the app portion separate and only include it if a certain attribute is set in the base template (which would only be set in the app cookbook).
Hi Dang
I did see the article you refer to.
If I am not mistaken , it talks about replacing templates in a wrapper cookbook.
I was wondering, if I can merge the template in base with the template in the wrapper cookbook.
So final output would be
final_conf = base_temp.conf + app_temp.conf
Is template merging possible?
Regards
mg
From: Dang.Nguyen@disney.com
To: chef@lists.opscode.com
Date: Thu, 16 Jul 2015 15:52:27 +0000
Subject: [chef] RE: Append to a template within recipe
From: Nguyen, Dang
Sent: Thursday, July 16, 2015 8:52 AM
To: 'chef@lists.opscode.com’
Subject: RE: [chef] Append to a template within recipe
You’d want to wrap your base cookbook in the app cookbook. Since you’ve already setup the dependency, your next step is to override the template source being referenced by the template resource. Julian Dunn wrote up a nice blog, entitled “Doing Wrapper Cookbooks Right” and addresses exactly how to specify a different template as the source from a wrapper cookbook.
I have a base cookbook and a app cookbook which depends on base.
The base cookbook has a template - base_temp.conf.erb which gets used inside the app cookbook
app_cookbook/recipe/default.rb has include_recipe ‘base’
Is there a way to append to the base template within app cookbook without modifying the template in the base cookbook as it is applicable only to this one app.
So can I have a app_temp.conf.erb which gets appended to the base_temp.conf in the recipe or maybe get the resource collection and append line by line to the base_temp.conf
I can get the template resource in the app recipe like so
It does sound like you should copy the base cookbook’s template into your
app cookbook and make the modifications there. It will be under your control
and easier to manage in the long run.
Does your config type support including? Because you could keep the app
portion separate and only include it if a certain attribute is set in the
base template (which would only be set in the app cookbook).
From: Nguyen, Dang
Sent: Thursday, July 16, 2015 8:52 AM
To: 'chef@lists.opscode.com mailto:chef@lists.opscode.com '
Subject: RE: [chef] Append to a template within recipe
You’d want to wrap your base cookbook in the app cookbook. Since you’ve
already setup the dependency, your next step is to override the template
source being referenced by the template resource. Julian Dunn wrote up a
nice blog, entitled “Doing Wrapper Cookbooks Right” and addresses exactly
how to specify a different template as the source from a wrapper cookbook.
I have a base cookbook and a app cookbook which depends on base.
The base cookbook has a template - base_temp.conf.erb which gets used inside
the app cookbook
app_cookbook/recipe/default.rb has include_recipe ‘base’
Is there a way to append to the base template within app cookbook without
modifying the template in the base cookbook as it is applicable only to this
one app.
So can I have a app_temp.conf.erb which gets appended to the base_temp.conf
in the recipe or maybe get the resource collection and append line by line
to the base_temp.conf
I can get the template resource in the app recipe like so
It does sound like you should copy the base cookbook’s template into your app cookbook and make the modifications there. It will be under your control and easier to manage in the long run. From: M G [mailto:meher03@hotmail.com]
Sent: Thursday, July 16, 2015 9:56 AM
To: chef@lists.opscode.com
Subject: [chef] RE: Re: RE: RE: Append to a template within recipe Hi Yoshi Unfortunately, no. Even if it did I cannot modify anything related to base ( due to process/policy/politics/etc) If I could, then many options would open up . Thank you for your suggestion. Regards mgDate: Thu, 16 Jul 2015 09:20:32 -0700
From: yoshi.spendiff@indochino.com
To: chef@lists.opscode.com
Subject: [chef] Re: RE: RE: Append to a template within recipeDoes your config type support including? Because you could keep the app portion separate and only include it if a certain attribute is set in the base template (which would only be set in the app cookbook).So something likeBase:attributes: default[‘myconf’][‘include_app’] = falsetemplate:<%= “include ‘./my.app.conf’” if node[‘myconf’][‘include_app’] %>App:attributes: default[‘myconf’][‘include_app’] = true
and deploy your app config to the same directory as the base conf. On Thu, Jul 16, 2015 at 8:59 AM, M G meher03@hotmail.com wrote:Hi Dang I did see the article you refer to. If I am not mistaken , it talks about replacing templates in a wrapper cookbook. I was wondering, if I can merge the template in base with the template in the wrapper cookbook. So final output would be final_conf = base_temp.conf + app_temp.conf Is template merging possible? Regards mg From: Dang.Nguyen@disney.com
To: chef@lists.opscode.com
Date: Thu, 16 Jul 2015 15:52:27 +0000
Subject: [chef] RE: Append to a template within recipe Here’s the blog: https://www.chef.io/blog/2013/12/03/doing-wrapper-cookbooks-right/
From: Nguyen, Dang
Sent: Thursday, July 16, 2015 8:52 AM
To: 'chef@lists.opscode.com’
Subject: RE: [chef] Append to a template within recipe
You’d want to wrap your base cookbook in the app cookbook. Since you’ve already setup the dependency, your next step is to override the template source being referenced by the template resource. Julian Dunn wrote up a nice blog, entitled “Doing Wrapper Cookbooks Right” and addresses exactly how to specify a different template as the source from a wrapper cookbook.
Cheers,
Dang Nguyen
From: M G [mailto:meher03@hotmail.com]
Sent: Thursday, July 16, 2015 8:41 AM
To: chef@lists.opscode.com
Subject: [chef] Append to a template within recipe Hi I have a base cookbook and a app cookbook which depends on base. The base cookbook has a template - base_temp.conf.erb which gets used inside the app cookbook app_cookbook/recipe/default.rb has include_recipe ‘base’ Is there a way to append to the base template within app cookbook without modifying the template in the base cookbook as it is applicable only to this one app. So can I have a app_temp.conf.erb which gets appended to the base_temp.conf in the recipe or maybe get the resource collection and append line by line to the base_temp.conf I can get the template resource in the app recipe like so run_context.resource_collection.lookup(
“template[#{base_template}]”)