ansible-wrapper

0.7.0 • Public • Published

ansible-wrapper

Wraps the ansible CLI in a convenient NodeJS wrapper.

Installation

You will need to have ansible installed on the same machine where your nodejs application will be running.

npm install ansible-wrapper

Examples

Basic usage

const Ansible = require('ansible-wrapper');
const cmd = new Ansible.Adhoc({
  hostPattern: 'localhost',
  module: 'command',
  freeForm: 'echo "hello world"'
});

const result = await cmd.execPromise();
console.log(result);

Daisy chain

Or daisy chain the applicable functions to set the options. This results in the same as previous example.

const Ansible = require('ansible-wrapper');
const cmd = new Ansible.Adhoc();
cmd.setHostPattern('localhost')
  .setModule('command')
  .setFreeForm('echo "hello world"');

const result = await cmd.execPromise();
console.log(result);

Custom arguments

Arguments which are not supported by this library, can be set by using the addArgument() method which Ansible.Adhoc inherits from Ansible.Cli.

const Ansible = require('ansible-wrapper');
const cmd = new Ansible.Adhoc({
  hostPattern: 'localhost',
  module: 'command',
  freeForm: 'echo "hello world"'
});

// add the arguments
cmd.addArgument('-C');
cmd.addArgument('-B', 8);
cmd.addArgument('--verbose');

Documentation

The code has extensive JsDoc available. This is not yet exposed on a dedicated site.

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.7.01latest

Version History

VersionDownloads (Last 7 Days)Published
0.7.01
0.6.11
0.6.01

Package Sidebar

Install

npm i ansible-wrapper

Weekly Downloads

3

Version

0.7.0

License

MIT

Unpacked Size

16.6 kB

Total Files

7

Last publish

Collaborators

  • steve2507