|
DistributionOften, you need to distribute files to your servers. The Files within a cookbook are where you can do just that.They are reached via the cookbook_file resource.A cookbook_file resource The above resource would create /usr/local/bin/apache2_module_conf_generate.pl from the apache2_module_conf_generate.pl file contained in the cookbook that was most specific to the Node executing the recipe. By default, it looks for File Specificity from the remote_url setting in the Client configuration. File SpecificityCookbooks will work on multiple platforms frequently, or distribute files that are only subtly different depending on the platform. Chef Cookbooks allow you to only specify those files one time, but make sure that the right file ends up on each system. Within a Cookbook's files or templates directories, you might find a directory structure like this:
Given this resource: A cookbook_file resource We would match:
In that order (given a Node named foo.example.com running Ubuntu 8.04). Then for example, if we put apache_module_conf_generate.pl under files/host-foo.example.com/ directory it will be only copied to the machine with the domain name foo.example.com. So, the rule distilled:
When does a file get transferred?When you run a cookbook_file resource, the client will calculate the checksum of local file. It compares this checksum against the checksum of the most specific available version of the file in the cookbook. If the checksums match, the file will not be transferred. Additionally, cookbook files are loaded lazily from the server--a cookbook may contain many cookbook files, but they are only transferred to the client as they are needed.
|
|
|



2 Comments
comments.show.hideOct 25, 2011
javier esteban
Good Morning,
I would like to do next things:
1) Create a sql file that contain the creation of database
2) This file put into the files directory, is it correct? is it possible?
3) In a recipe file call execute this file that generate the database, is it possible? How to do?
Best Regards,
Javier
Jan 24, 2012
smarx@moxiesoft.com
Does the cookbook_file follow symlinks? I've got several hosts that need the same config for some cookbook_files. I'd really like to make one copy of this and symlink all the other host directories off of it, but this doesn't seem to work.