Closed MohamedKHALILRouissi closed 2 months ago
Hi @MohamedKHALILRouissi! Thank you for opening this issue!
You're currently utilizing the AnsiblePlaybookExecute
, which is a ready-to-go executor and doesn't offer much room for customization.
To disable stdout, I suggest using the DefaultExecute
and utilizing the WithWrite method to set the writer as io.Discard
.
playbookCmd := playbook.NewAnsiblePlaybookCmd(
playbook.WithPlaybooks("site.yml"),
playbook.WithPlaybookOptions(ansiblePlaybookOptions),
)
exec := execute.NewDefaultExecute(
execute.WithCmd(playbookCmd),
execute.WithErrorEnrich(playbook.NewAnsiblePlaybookErrorEnrich()),
execute.WithWrite(io.Discard),
)
exec.Execute(context.TODO())
I hope it can help you!
is possible to catch each step output , let say that have i have single yaml playbook with 4 step , failed at step 3 create log for the failed creation ? ( without the stdout )
hi @MohamedKHALILRouissi! That won't be possible by configuring the writer, at least not straightforwardly, because the DefaultExecute's writer captures the entire command execution.
Did you explore the JSON stdout callback? It might help you customize how you control the output. However, one drawback of the JSON stdout callback is that you won't get the output until the execution is completed.
Here you have an example of how to enable the JSON stdout callback with go-ansible.
@MohamedKHALILRouissi let me know if any further assistance is required, otherwise, I will close the issue.
@MohamedKHALILRouissi I close the issue. If you have any questions, please, feel free open a new issue.
am not sure exactly how to disable to stdout any help please and thanks
` func cloud_server_configuration(server_ip string, os_type string, user string) {
} `