Giter Site home page Giter Site logo

mitchd / node-ansible Goto Github PK

View Code? Open in Web Editor NEW

This project forked from shaharke/node-ansible

0.0 1.0 0.0 576 KB

Programmatic interface in Node.js for executing Ansible ad-hoc commands and playbooks

License: MIT License

Shell 0.45% JavaScript 99.55%

node-ansible's Introduction

node-ansible Build Status

Programmatic interface in Node.js for executing Ansible ad-hoc commands and playbooks

Warning: this package is still under development. API might break between minors.

Installation

npm install node-ansible --save

NOTE: I think it goes without saying, but I'll mention it anyway - you MUST have ansible installed on the same machine on which your node process is going to run.

Crash Course

var Ansible = require('node-ansible');
var command = new Ansible.AdHoc().module('shell').hosts('local').args("echo 'hello'");
command.exec();

is equivalent to:

ansible local -m shell -a "echo 'hello'"
var playbook = new Ansible.Playbook().playbook('my-playbook');
playbook.exec();

is equivalent to:

ansible-playbook myplaybook.yml

Let's execute:

var promise = playbook.exec();
promise.then(function(successResult) {
  console.log(successResult.code); // Exit code of the executed command
  console.log(successResult.output) // Standard output/error of the executed command
}, function(error) {
  console.error(error);
})

We can also get the results of a command streamed in real time (from both playbooks and adhoc commands):

playbook.on('stdout', function(data) { console.log(data.toString()); });
playbook.on('stderr', function(data) { console.log(data.toString()); });
var promise = playbook.exec();

Full Documentation

Running tests:

npm test

License

MIT

node-ansible's People

Contributors

deployable avatar nikolovivan avatar shaharke 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.