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
Hi,
first of all, I wanted to congratulate you on the excellent library you have created.
I wanted to ask you if there are any examples of reading playbook logs in real-time.
Let me explain my need, I need to read logs generated in real-time and push them to a rabbitmq queue. Then they will be consumed asynchronously and saved to a database.
At the end of the script I send the ‘recap’ of the execution via your ParseJSONResultsStream() method.
Thank you very much
Simone
The text was updated successfully, but these errors were encountered:
Thank you so much! I'm glad to hear that the go-ansible library is proving useful for you. :)
I assume that by 'reading the playbook logs,' you are referring to accessing the console output during execution, am I correct?
If you configure your execution to use the JSON stdout callback, it won't be possible to read logs in real-time, as Ansible only provides the output at the end of the execution.
However, you can read the Ansible output in real-time using other stdout callback methods. Keep in mind, though, that parsing the output may be more challenging in such cases.
If your goal is to send the output to a RabbitMQ queue, one approach is to create a custom driver that implements the io.Writer interface. You can then set the DefaultExecute to use this driver as its writer by using the WithWrite method.
By default, the output mechanism writes each captured line from the Ansible playbook output to os.Stdout. Replacing the writer with your custom implementation will redirect the output to your desired destination.
The go-ansible library captures the stdout of the Ansible process and allows you to handle it. You can take advantage of the TransformerFuncs to add metadata to each line. TransformerFuncs enables you to customize the output before sending it to the writer.
This example illustrates how to use transformers and shows how to create a custom transformer.
Hi,
first of all, I wanted to congratulate you on the excellent library you have created.
I wanted to ask you if there are any examples of reading playbook logs in real-time.
Let me explain my need, I need to read logs generated in real-time and push them to a rabbitmq queue. Then they will be consumed asynchronously and saved to a database.
At the end of the script I send the ‘recap’ of the execution via your ParseJSONResultsStream() method.
Thank you very much
Simone
The text was updated successfully, but these errors were encountered: