ansible-cli-js
TypeScript icon, indicating that this package has built-in type declarations

2.0.5 • Public • Published

ansible-cli-js

A node.js wrapper for the ansible command

NPM NPM

NPM version NPM downloads

Installation

Step 1: Prerequisites

Ansible must be installed and accessible in the path

Step 2: Installation

npm install ansible-cli-js

Then:

var ansibleCli = require('ansible-cli-js');
 

Usage

With promise:

var Options = ansibleCli.Options;
var Ansible = ansibleCli.Ansible;
 
var options = new Options(
    /* currentWorkingDirectory */ 'ping'
);
 
var ansible = new Ansible(options);
 
ansible.command('all -m ping  --inventory-file=./inventory --connection=local').then(function (data) {
  console.log('data = ', data); 
});
 
//data = {
//  command: 'ansible all -m ping --inventory-file=./inventory --connection=local ',
//  raw: '["localhost | success >> {\\n    \\"changed\\": false, \\n    \\"ping\\": \\"pong\\"\\n}\\n\\n",""]'
//}

With callback:

 
ansible.command('ansible all -m ping --inventory-file=./inventory --connection=local', function (err, data) {
  console.log('data = ', data);
});
 

Typescript:

import { Ansible, Options } from 'ansible-cli-js';
 
const options = new Options(
  /* currentWorkingDirectory */ 'ping'
);
 
const ansible = new Ansible(options);
 
ansible.command('all -m ping --inventory-file ./inventory --connection local').then(function (data) {
  console.log('data = ', util.inspect(data, { depth: 10 }));
});
 

License

MIT

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 2.0.5
    2
    • latest

Version History

Package Sidebar

Install

npm i ansible-cli-js

Weekly Downloads

2

Version

2.0.5

License

MIT

Unpacked Size

8.43 kB

Total Files

6

Last publish

Collaborators

  • mattqs