add ability to enable verbose logging

This commit is contained in:
2024-05-17 00:20:33 +03:00
parent 5ac4607f79
commit 36d886d94a
7 changed files with 47 additions and 19 deletions

View File

@@ -56,19 +56,26 @@ func CopyK8SAdminConfig(pathInDataDir string) {
}
func runPlaybook(playbookPath string, tags string) {
config := config.GetConfig()
var callbackExecute execute.Executor
playbookOptions := getPlaybookParameters(tags)
playbookCmd := playbook.NewAnsiblePlaybookCmd(
playbook.WithPlaybooks(playbookPath),
playbook.WithPlaybookOptions(&playbookOptions),
)
exec := stdoutcallback.NewDebugStdoutCallbackExecute(
execute.NewDefaultExecute(
execute.WithCmd(playbookCmd),
execute.WithErrorEnrich(playbook.NewAnsiblePlaybookErrorEnrich()),
),
execute := execute.NewDefaultExecute(
execute.WithCmd(playbookCmd),
execute.WithErrorEnrich(playbook.NewAnsiblePlaybookErrorEnrich()),
)
err := exec.Execute(context.Background())
if config.Verbose {
callbackExecute = stdoutcallback.NewDebugStdoutCallbackExecute(execute)
} else {
callbackExecute = stdoutcallback.NewDenseStdoutCallbackExecute(execute)
}
err := callbackExecute.Execute(context.Background())
if err != nil {
panic(err)
}