Closed wahello closed 3 years ago
HI @wahello
could you extend you question or give some more context, please?
Folder https://github.com/apenella/go-ansible/tree/master/examples
has several examples where you could see how to manage Ansible results.
Thanks!
@apenella Like executing builtin module setup
, if successful, how to obtain the hardware info of the results in code? The result is printed in log.
Hi @wahello!
go-ansible
executes ansible
commands. To achieve setup
's module results you need to update ansible playbook to do that. You could do it using ansible's debug
module.
Let me know if you have any update! Thanks
@apenella I must missed something. How to get the print log, excuting this line
err := adhoc.Run(context.TODO())
in examples
when err is nil?.
I got it.
@apenella I must missed something. How to get the print log, excuting this line
err := adhoc.Run(context.TODO())
in examples when err is nil?.
hi, Have you found a solution?i need to get adhoc result also.
Hi! @cyberchao by default, when you run an ad hoc command, its output is printed to stdout.
In case you would manage the output, such as is done when you use json
stdout callback, you need to create your own executor and store the command output to a buffer.
Take a look at that example:
https://github.com/apenella/go-ansible/blob/master/examples/json-stdout-ansibleplaybook/json-stdout-ansibleplaybook.go#L31
I hope it could help you! Let me know if you need anything else.
@apenella Exactly!
Hi! @cyberchao by default, when you run an ad hoc command, its output is printed to stdout.
In case you would manage the output, such as is done when you use
json
stdout callback, you need to create your own executor and store the command output to a buffer. Take a look at that example: https://github.com/apenella/go-ansible/blob/master/examples/json-stdout-ansibleplaybook/json-stdout-ansibleplaybook.go#L31I hope it could help you! Let me know if you need anything else.
How to get success result?