Skip to content

Instantly share code, notes, and snippets.

@zeitounator
Created July 29, 2020 06:44
Show Gist options
  • Save zeitounator/52956f5ea378335c5e6a9b47df13edca to your computer and use it in GitHub Desktop.
Save zeitounator/52956f5ea378335c5e6a9b47df13edca to your computer and use it in GitHub Desktop.
---
- name: Node test
hosts: localhost
gather_facts: False
tasks:
- debug:
var: titi
var Ansible = require('node-ansible')
var command = new Ansible.Playbook().playbook('test');
command.on('stdout', function(data) { console.log(data.toString()); });
command.on('stderr', function(data) { console.log(data.toString()); });
command.variables({toto: 'Fake var we don\'t use', titi: 'Our test var set in js'});
command.exec();
$ node test_node_script.js
PLAY [Node test] ***************************************************************
TASK [debug] *******************************************************************
ok: [localhost] => {
"titi": "Our test var set in js"
}
PLAY RECAP *********************************************************************
localhost : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment