Chef Node Bootstrap Version 1

This handler bootstraps a node in chef by using an external ruby instance to call chef. Before uploading this handler, make sure to include a chef repository containing a knife.rb file either in the resources directory of the handler file or somewhere else on the task engine server. Once the handler starts running, it begins by error checking the parameters based on what type of server the task engine is running on (windows or unix).

On Windows machine the process consists of:

  • Loading and accepting the EULA for PsExec.exe (which will be used to run knife as a background process)

On both Unix and Windows machines the process consists of:

  • Checking if a knife.rb file is accessible from the handler

  • Checking if ruby with the json gem are installed (json is automatically included in ruby 1.9 and later)

  • Checking if the task location provided in the info values contains a source with the name provided in the parameters

If none of these situations throw an error, the handler then moves onto calling a script that handles the actual knife bootstrap call. This script is passed a json string of all the parameters provided to the handler. After creating a file within the handler resources folder that will contain all of the logging information for the bootstrap call (each call will have a different file, with the form of bootstraprun[epoch timestamp].log). The actual knife call that will be made follows the form of:

knife bootstrap [server name] -x [user config] -N "[node name]" -r "[recipe]" -c [knife.rb location]

The bootstrapping process can take a long time, so once the script is started, the handler ends and is put into a deferred state until the bootstrap command is complete. Once that finishes, the script sends the deferral token back to the task tree using the Kinetic Task API and net/http (example POST that the script uses is below). Once the deferral token is recieved, the handler completes its process.

Task 3 Deferral Callback

POST [task_location]/rest/v1/Trigger/createDeferred action=Complete&token=[deferral token]

Task 4 Deferral Callback

POST [task_location]/app/api/v1/complete-deferred-task/[source name] { "token" : [deferral token] }

Info Values

Two info values need to be provided with Chef Node Bootstrap. [Knife Location] The path to the knife.rb file on the server. If an absolute path is not given, the handler assumes the file was placed in the resources directory.

ie. chef-repo/.chef/knife.rb means that the file is located at chefnodebootstrap_v1/handler/resources/chef-repo/.chef/knife.rb [Task Location] The url where your task instance is located


Knife Configuration

Information on how to configure knife on your machine can be found at --


Name Description
Server Name The name for the server you wish to bootstrap.
Node Name The name that will be assigned to the node.
Recipe The recipe that you want to be put on the new node.
User Config The user config that will be used to setup the new node.
Source Name The source name that will be used to automatically complete the deferral when the bootstrap is complete.

Sample Configuration

Name Description
Server Name
Node Name handler-test
Recipe recipe[sample-recipe]
User Config ubuntu --sudo
Source Name Playground


Name Description
deferral_token The deferral token that will be used to restart the deferred node after the bootstrap is complete.


chefnodebootstrap (2014-10-08)

  • Initial version. See README for details.

Related Handlers

Chef Add Recipe to Run List
Adds a recipe to a run list for a specific Node in Chef.
Chef Retrieve Cookbook
Retireve a Cookbook from Chef-io for an organization.
Chef Node Attribute Delete
Deletes an attribute from an existing Chef Server node
Chef Node Delete
Deletes a node from a Chef server.
Chef Remove Recipe from Run List
Removes a recipe from from a run list in a node.
Chef Retrieve Cookbooks
Retrieves a list of Cookbooks from Chef-io from an organization.
Chef Retrieve Node
Retrieves a information about a node in Chef-io within an organization.
Chef Retrieve Nodes
Retrieves a list of nodes from Chef-io from an organization.
Chef Retrieve Run List
Retrieves a Runlist from Chef for a node.