Skip to content

delivery_chef_cookbook

Tom Duffield edited this page Jul 29, 2015 · 3 revisions

Use the delivery_chef_cookbook resource to upload a single Chef cookbook to one or more Chef Servers. This resource, utilized in a Chef Delivery pipeline, allows you to create a workflow similar to that of Grocery Delivery where you ship out cookbooks to a fleet of Chef Servers across your infrastructure.

Usage

The purpose of delivery_chef_cookbook is to upload a cookbook to one or more Chef Servers. These Chef Servers are represented as instances of the DeliverySugar::ChefServer class. To create an instance of this class you need only provide it a path to a knife.rb file you have on disk. It is assumed that this knife.rb already exists and functions independently of Chef Delivery (meaning any client keys or encrypted_data_bag_secrets are correctly referenced). You will need to place the files on disk, either manually or using Chef resources, to make

chef_server_obj = DeliverySugar::ChefServer.new("/path/to/knife.rb")

Once you have an instance of the DeliverySugar::ChefServer class assigned to a variable in your recipe, you can pass that variable into the chef_server attribute of the delivery_chef_cookbook resource.

chef_server_obj = DeliverySugar::ChefServer.new("/path/to/knife.rb")

delivery_chef_cookbook "cookbook_name" do
   path "/path/to/cookbook"
   chef_server chef_server_obj
   action :upload
end

If you wish to upload to more than one Chef Server, you can pass in multiple instances of the DeliverySugar::ChefServer class into the chef_server attribute of the delivery_chef_cookbook using an array.

chef_server_obj1 = DeliverySugar::ChefServer.new("/path/to/knife1.rb")
chef_server_obj2 = DeliverySugar::ChefServer.new("/path/to/knife2.rb")

delivery_chef_cookbook "cookbook_name" do
   path "/path/to/cookbook"
   chef_server [chef_server_obj1, chef_server_obj2]
   action :upload
end

Failure tolerance in multiple Chef Server scenarios

In the scenario where you are uploading a cookbook to multiple Chef Servers, the delivery_chef_cookbook will attempt to upload to all the Chef Servers even if the upload to a single Chef Server fails. For example, if you are uploading to serverA, serverB, and serverC, and the upload fails on serverA, delivery_chef_cookbook will still try to upload the cookbook to serverB and serverC. It should be noted that a failure to upload to at least one Chef Server will result in the chef-client run failing resulting in a failed stage/phase run.

Clone this wiki locally