Skip to content

no result code with promise #41

@zerr0s

Description

@zerr0s

Hi,

Forgive me for my bad english. I'm trying to run my playbook from nodejs. My playbook is running well, but I can't get the result code of execution with promise:

` var Ansible = require('node-ansible');

                          var command = new Ansible.Playbook().playbook('main');
                          
                          command.inventory(ip+","); //the ip adress is dynamic so I can't use an inventory
                          if (image_type === "Linux") {
                            command.variables({
                              myvar1: "test variable from node js",
                              myvar2: "another test"
                            });
                            command.verbose('v');
                          }
                          
                          /*command.on('stdout', function(data) {
                            logger.info(data.toString());
                          });
                          command.on('stderr', function(data) {
                            logger.error(data.toString());
                          });*/
                       
                          var promise = command.exec({cwd:"../ansible",buffered:true});
                          
                          promise.then(function(result) {
                            // nothing is logged on console
                            console.log(result.output);
                            console.log("===========>"+result.code);
                          });

                          /*var promise = command.exec({cwd: "../ansible", buffered: true});
                          promise.then(function(data){
                            console.log("===========> unbuf: "+data.output);
                            console.log("===========> unbuf: "+data.code);
                          });*/

`
Any idea ?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions