Code Monkey home page Code Monkey logo

chef-api's Introduction

chef-api

##About

###Description A simple client providing access the chef server api, implemented in nodejs

###Author Norman Joyner - [email protected]

##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", // (required unless using 'client_name') a chef user
    client_name: "myclientname", // (required unless using 'user_name') a chef client
    key_path: "/Users/myusername/.chef/myusername.pem", // (required unless using 'key') path to private key
    key: "-----BEGIN RSA PRIVATE KEY-----\n...\n-----END RSA PRIVATE KEY-----", // (required unless using 'key_path') contents of private key
    organization: "myorganization", // (required unless using 'url') organization name for use with hosted chef
    url: "https://mychefserver.com/organizations/SHORT_ORGNAME", // (required unless using 'organization') url for use with local chef server
    ca: "-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----", // (optional) if this key is omitted, then the default CA chain will be used. If null, the client will operate unsafely and not validate the server's certificate, it set to a certificate list explicitly, that list will be used as the CA chain.
    timeout: 15000 // (optional) request timeout in ms
}

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/organizations/default"
}

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.chef.io/api_chef_server.html for API specifics.

chef-api's People

Contributors

alexclinebb avatar andersje avatar danbb3 avatar gdbtek avatar howardengelhart avatar markcallen avatar normanjoyner avatar postwait avatar robraux avatar sgentle avatar willm avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.