From b453e1efb5c50a9e3798ea0058e00c060913aa98 Mon Sep 17 00:00:00 2001 From: Craig Comstock Date: Fri, 11 Oct 2024 10:19:05 -0500 Subject: [PATCH] try to capture validation output and print out in case of failure to validate --- lib/service_config.cf | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/service_config.cf b/lib/service_config.cf index 73746cdb1a..639f478116 100644 --- a/lib/service_config.cf +++ b/lib/service_config.cf @@ -21,9 +21,11 @@ bundle agent service_config(service_name,config_template_path,config_final_path, bundle agent validate_config_and_restart_service(staged_config,validate_config_command,config_final_path,service_name) { + vars: + "validation_output" string => "$(staged_config)-validation.log"; classes: - "config_validated" expression => returnszero("$(validate_config_command) $(staged_config)", "useshell"); + "config_validated" expression => returnszero("$(validate_config_command) $(staged_config) 2>&1 >$(validation_output)", "useshell"); "config_final_exists" expression => fileexists("$(config_final_path)"); "staged_config_newer" expression => isnewerthan("$(staged_config)", "$(config_final_path)"); @@ -58,4 +60,5 @@ bundle agent validate_config_and_restart_service(staged_config,validate_config_c "$(staged_config) validates" if => "config_validated"; "$(config_final_path) exists" if => "config_final_exists"; "$(staged_config) is newer than $(config_final_path)" if => "staged_config_newer"; + "validation output ${with}" with => readfile("${validation_output}"); }