A Blog

An occasional data tap into Peter Burkholder’s brain

Create Chef Client via Api With Validation Key

| Comments

So, suppose you have a Chef validator, how do you create a node client?

Like this:

ORG=“my_org” CHEF=“https://api.opscode.com/organizations/$ORG” CLIENT=userhack VALIDATION_KEY=“validation.pem” VALIDATION_USER=“$ORG-validator” # default open-source value is ‘’chef-validator’’

export PATH=$PATH:/opt/chef/bin

knife exec \ -E ‘’client_desc = { “name” => “’‘$CLIENT’‘”, “admin” => false}; n=api.post “/clients”, client_desc; puts n[“private_key”]’‘ \ -u $VALIDATION_USER -k $VALIDATION_KEY > client.pem

Now you can use the client.pem in a knife.rb:

cat << END > knife.rb log_level :info log_location STDOUT node_name “$CLIENT” client_key “client.pem” chef_server_url “$CHEF” END