A node.js wrapper for the ansible command
Ansible must be installed and accessible in the path
npm install ansible-cli-js
Then:
varansibleCli=require('ansible-cli-js');With promise:
varOptions=ansibleCli.Options;varAnsible=ansibleCli.Ansible;varoptions=newOptions(/* currentWorkingDirectory */'ping');varansible=newAnsible(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';constoptions=newOptions(/* currentWorkingDirectory */'ping');constansible=newAnsible(options);ansible.command('all -m ping --inventory-file ./inventory --connection local').then(function(data){console.log('data = ',util.inspect(data,{depth: 10}));});MIT

