Chef files

Chef is a powerful configuration management tool that turns infrastructure into code. With the help of Chef, Users can easily manage, configure and deploy the resources across the network from the central location of the environment (cloud, on-premises, or hybrid).


The directory contains all the files that we need to copy to the servers as part of our chef cookbook. Let's take an example. Imagine we are trying to deploy apache or Nginx on the nodes using Chef.

After installing apache using standard chef resources(like package, file, directory, service, etc.), we will have to deploy web content as well in there. The static files that we want to serve using the webserver that is.

we can actually use this directory of chef cookbook to place our required files and then copy them down to the nodes using the resource called cookbook_file as shown below.

we have the file index.html inside chef-repo/cookbooks/{cookbook name}/files/default/ location of our cookbook. we are now willing to copy that index.html file to the nodes. Note: Note replace {cookbook name} with the actual name of the cookbook.

cookbook_file '/var/www/html/index.html' do

  source 'index.html'

  owner 'www-data'

  group 'www-data'

  mode '0755'

  action :create


The above will copy index.htmlfile located at chef repo/cookbooks/{cookbook_name}/files/default/ down to the node.

Relevant Blogs:

Chef fact 

Chef files 

Manage linux package in puppet 

Kubernetes blue/green deployment

Recent Comments

No comments

Leave a Comment