Usage of 'site-cookbooks' for template customizing


#1

Hello,

We have used the following documentation section in order to customize
templates from the mysql and php cookbooks:
http://wiki.opscode.com/display/chef/Cookbooks#Cookbooks-CustomizingTemplatesandFiles

so we created a site-cookbooks folder, added it to the cookbook_path config for
knife, and created apache et mysql directory structure for the templates in
order to override my.cnf.erb for mysql and debian/php.ini.erb for php

but when running the command

knife cookbook upload -a

we got the following warning:

WARNING: * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *


WARNING: The cookbooks: mysql, php exist in multiple places in your
cookbook_path.
A composite version of these cookbooks has been compiled for uploading.

IMPORTANT: In a future version of Chef, this behavior will be removed and you
will no longer
be able to have the same version of a cookbook in multiple places in your
cookbook_path.
WARNING: The affected cookbooks are located:
mysql:
/root/svnChef/trunk/chef-repo/cookbooks/mysql
/root/svnChef/trunk/chef-repo/site-cookbooks/mysql
php:
/root/svnChef/trunk/chef-repo/cookbooks/php
/root/svnChef/trunk/chef-repo/site-cookbooks/php
WARNING: * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *


Could you let us know what we are doing wrong please ?

Thanks in advance for your answers.

Best regards,
Christophe


#2

Christophe,

Overriding templates like that still works with chef-0.10, but it is
deprecated and you should not use it for new work.

One technique I have used is to make a new cookbook named
mysql-customizations with a single recipe as follows:

site-cookbooks/mysql-customizations/metadata.rb

depends “mysql”

site-cookbooks/mysql-customizations/recipes/default.rb

include_recipe "mysql"
resources(:template => “/etc/my.cnf”).instance_exec do
cookbook "mysql-customization"
end

site-cookbooks/mysql-customizations/templates/default/my.cnf.erb

custom custom custom

your customized version of my.cnf.erb …

custom custom custom

And then, in your role/run-list, instead of using recipe[mysql], use
recipe[mysql-customizations].

Cheers,
Jay Feldblum

On Tue, Apr 3, 2012 at 1:57 PM, cl.subscription@gmail.com wrote:

Hello,

We have used the following documentation section in order to customize
templates from the mysql and php cookbooks:

http://wiki.opscode.com/display/chef/Cookbooks#Cookbooks-CustomizingTemplatesandFiles

so we created a site-cookbooks folder, added it to the cookbook_path
config for
knife, and created apache et mysql directory structure for the templates in
order to override my.cnf.erb for mysql and debian/php.ini.erb for php

but when running the command

knife cookbook upload -a

we got the following warning:

WARNING: * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *


WARNING: The cookbooks: mysql, php exist in multiple places in your
cookbook_path.
A composite version of these cookbooks has been compiled for uploading.

IMPORTANT: In a future version of Chef, this behavior will be removed and
you
will no longer
be able to have the same version of a cookbook in multiple places in your
cookbook_path.
WARNING: The affected cookbooks are located:
mysql:
/root/svnChef/trunk/chef-repo/cookbooks/mysql
/root/svnChef/trunk/chef-repo/site-cookbooks/mysql
php:
/root/svnChef/trunk/chef-repo/cookbooks/php
/root/svnChef/trunk/chef-repo/site-cookbooks/php
WARNING: * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *


Could you let us know what we are doing wrong please ?

Thanks in advance for your answers.

Best regards,
Christophe


#3

On Tue, Apr 3, 2012 at 1:57 PM, cl.subscription@gmail.com wrote:

Hello,

We have used the following documentation section in order to customize
templates from the mysql and php cookbooks:
http://wiki.opscode.com/display/chef/Cookbooks#Cookbooks-CustomizingTemplatesandFiles

so we created a site-cookbooks folder, added it to the cookbook_path config for
knife, and created apache et mysql directory structure for the templates in
order to override my.cnf.erb for mysql and debian/php.ini.erb for php

but when running the command

knife cookbook upload -a

Could you let us know what we are doing wrong please ?

Thanks in advance for your answers.

Best regards,
Christophe

You aren’t doing anything wrong per se. The functionality you’re using
is most likely going to be deprecated. You can search the archives for
"cookbook shadowing" but essentially the merged view of a cookbook and
precedence will be going away.

You can contribute your voice on the ticket here:

http://tickets.opscode.com/browse/CHEF-2308