NOTE: I've forked it from Shaharke to accept some of the PRs to fit my requirements and modify at my will. This repo has merged the following PRs PR1, PR2, PR3.
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 = ;var command = ;command;
is equivalent to:
ansible local -m shell -a "echo 'hello'"
var playbook = ;playbook;
is equivalent to:
ansible-playbook myplaybook.yml
Let's execute:
var promise = playbook;promise
We can also get the results of a command streamed in real time (from both playbooks and adhoc commands):
playbook;playbook;var promise = playbook;
Running tests:
npm test