Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yvesh/node-ansible
Programmatic interface in Node.js for executing Ansible ad-hoc commands and playbooks
https://github.com/yvesh/node-ansible
Last synced: about 1 month ago
JSON representation
Programmatic interface in Node.js for executing Ansible ad-hoc commands and playbooks
- Host: GitHub
- URL: https://github.com/yvesh/node-ansible
- Owner: yvesh
- License: mit
- Fork: true (shaharke/node-ansible)
- Created: 2020-11-15T12:54:23.000Z (almost 4 years ago)
- Default Branch: updates
- Last Pushed: 2020-11-15T13:32:31.000Z (almost 4 years ago)
- Last Synced: 2024-08-08T12:28:20.131Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 590 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
node-ansible-control
============> Updated Fork of https://github.com/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-control --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-control');
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)