You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
for compatibility, option must be toggled on using exec({json: true});
I added to silent mode to shelljs,
for compatibility, option must be toggled on using exec({silent: true});
I'ld test more as soon (code) as I far as I would use ansible for my projects.
I'ld have doc if accepted too ;)
Ex:
varAnsible=require('node-ansible');varcmd=newAnsible.AdHoc().hosts('call').module('mysql_replication').user('root').args({mode: 'getslave'}).verbose(0);vargo=cmd.exec({json: true,silent: true});go.then(function(result){for(variinresult.json){console.log('Host: ',result.json[i].host,' DB is ',result.json[i].data['Slave_IO_Running'],result.json[i].data['Slave_SQL_Running'],' with ',result.json[i].data['Seconds_Behind_Master'],'s');}}
results:
Host: HOST1 DB is Yes Yes with 0 s
Host: HOST2 DB is Yes Yes with 0 s
Host: HOST3 DB is Yes Yes with 0 s
@KRMV Thanks for the effort! I think I understand the motivation around this pull request, but I have a few concerns:
Every code added to the project should be fully tested.
I think that any execution of shelljs should be silent. It was an error on my part that it wasn't. What do you think about always calling shelljs with the silent flag?
I will probably completely re-design output handling to be a) more modular and b) to support streaming. By modular I mean that decoders (such as the JSON decoder you wrote) should be plugged into an execution and not simply enabled using an option flag. Also, the fact that we need to wait for the whole execution to complete before giving access to the output is wrong. Output should be streamed. If I merge your code now, it'll be harder for me to move to streaming.
About your points:
1/ I'll see to design test, when I will deeply integrate node with ansible, to make "dynamic" ansible script ;) So, as I'm quite busy, it will not be necessary soon :(
2/ I made a auto-off silent mode, to be fully compatible with your code results, but, we can easily toggle to auto-on
It just need to patch 7ef78e7 by setting silent to false.
3/ JSON converter can be use as a single module, directly inside the go.then method, so won't change your code, and could be adapted later when you redesign all.
So, I can patch 2/, setting default to false, enabling options using ({silent: false}), allowing "debug" (always useful for dumb things ;)) with ({silent: true}) and publish a pull request with just that one.
And seeing to 1/+3/ when will be able to test.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I need to be able to parse ansible response as JSON, and having silent mode.
So, now, it can add a json array to result, which is a collection of object using this model:
{ "host": "XXX", "code": "success|FAILED", "data": {"var1": "value1", "var2": "value2", ...} }so final result is :
{ "code": "XXX", "output": "XXX", "json": [ { "host": "XXX", "code": "XXX", "data": "XXX" }, {}, "..." ] }for compatibility, option must be toggled on using exec({json: true});
I added to silent mode to shelljs,
for compatibility, option must be toggled on using exec({silent: true});
I'ld test more as soon (code) as I far as I would use ansible for my projects.
I'ld have doc if accepted too ;)
Ex:
results: