chef-api
##About
###Description
A simple client providing access the chef server api, implemented in nodejs
###Author
Norman Joyner - norman.joyner@gmail.com
##Getting Started
###Installation
npm install chef-api
###Configuration
Simply require the chef-api module, instantiate a new object, and call the .config()
method to start accessing the Chef API.
The object passed to the .config()
method should be configured as follows:
var options = {
user_name: "myusername",
client_name: "myclientname",
key_path: "/Users/myusername/.chef/myusername.pem",
key: "-----BEGIN RSA PRIVATE KEY-----\n...\n-----END RSA PRIVATE KEY-----",
organization: "myorganization",
url: "https://mychefserver.com:4000",
ca: "-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----",
}
chef.config(options);
You are now free to make API calls.
###Examples
Example usage with hosted chef server, accessing API using a user's pem path:
var ChefApi = require("chef-api");
var chef = new ChefApi();
var options = {
user_name: "myusername",
key_path: "/Users/myusername/.chef/myusername.pem",
organization: "myorganization"
}
chef.config(options);
chef.getNodes(function(err, res){
if(err)
throw err;
console.log(res);
});
Example usage with private chef server, accessing API using a client's pem contents:
var ChefApi = require("chef-api");
var chef = new ChefApi();
var options = {
client_name: "myclientname",
key: "-----BEGIN RSA PRIVATE KEY-----\n...\n-----END RSA PRIVATE KEY-----",
url: "https://mychefserver.com:4000"
}
chef.config(options);
chef.getNode("mynodes.fqdn", function(err, res){
if(err)
throw err;
console.log(res);
});
###API Methods
chef-api provides a high level abstraction from the Chef Server API. Please consult the official docs at http://docs.opscode.com/api_chef_server.html for API specifics.