# node-ansible

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

Latest version **0.5.5** (published 2016-02-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install node-ansible
pnpm add node-ansible
yarn add node-ansible
bun add node-ansible
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.5.5 |
| Published | 2016-02-12 |
| First published | 2014-01-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 131 |
| Author | Shahar Kedar |
| Maintainers | shaharke |
| Keywords | ansible, api, programmatic |

## Links

- npm: https://www.npmjs.com/package/node-ansible
- Repository: https://github.com/shaharke/node-ansible
- Homepage: https://github.com/shaharke/node-ansible#readme
- Issues: https://github.com/shaharke/node-ansible/issues
- npm.io page: https://npm.io/package/node-ansible

## Dependencies (3)

- [q](https://npm.io/package/q.md) ~1.0.0
- [mock-spawn](https://npm.io/package/mock-spawn.md) ^0.2.6
- [underscore](https://npm.io/package/underscore.md) ~1.5.2

## Recent versions

- 0.5.5 (latest) — 2016-02-12
- 0.5.4 — 2015-12-19
- 0.5.3 — 2015-12-19
- 0.5.2 — 2015-09-24
- 0.5.1 — 2015-09-22
- 0.5.0 — 2015-09-22
- 0.4.0 — 2015-08-02
- 0.3.0 — 2015-02-10
- 0.2.1 — 2014-02-06
- 0.2.0 — 2014-02-05
- 0.1.0 — 2014-01-18
- 0.0.1 — 2014-01-18

## README

node-ansible [![Build Status](https://travis-ci.org/shaharke/node-ansible.png?branch=develop)](https://travis-ci.org/shaharke/node-ansible)
============

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

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

is equivalent to:

```shell
ansible local -m shell -a "echo 'hello'"
```

```javascript
var playbook = new Ansible.Playbook().playbook('my-playbook');
playbook.exec();
```

is equivalent to:

```shell
ansible-playbook myplaybook.yml
```

Let's execute:

```javascript
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):
```javascript
playbook.on('stdout', function(data) { console.log(data.toString()); });
playbook.on('stderr', function(data) { console.log(data.toString()); });
var promise = playbook.exec();
```

[Full Documentation](http://shaharke.github.io/node-ansible)

### Running tests:

`npm test`

### License

[MIT](https://github.com/shaharke/node-ansible/blob/master/LICENSE)

---
_Source: https://npm.io/package/node-ansible · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
