From 821ea3bc157be21e3c00e7aecd0814cbf2b2a852 Mon Sep 17 00:00:00 2001 From: Felix Dallidet Date: Tue, 24 Sep 2019 11:51:52 +0200 Subject: [PATCH] Fixes #15783: Make class_prefix unique --- tree/20_cfe_basics/ncf_lib.cf | 23 ++++++++++++------- tree/30_generic_methods/command_execution.cf | 17 ++++++++++---- .../command_execution_result.cf | 20 +++++++++++----- tree/30_generic_methods/service_action.cf | 12 ++++++---- .../service_check_disabled_at_boot.cf | 14 ++++++----- .../service_check_running.cf | 14 ++++++----- .../service_check_running_ps.cf | 14 ++++++----- .../service_check_started_at_boot.cf | 12 ++++++---- tree/30_generic_methods/service_disabled.cf | 17 ++++++++------ tree/30_generic_methods/service_enabled.cf | 13 +++++++---- .../service_ensure_running_path.cf | 3 ++- tree/30_generic_methods/service_restart.cf | 5 ++-- tree/30_generic_methods/service_restart_if.cf | 12 ++++++---- tree/30_generic_methods/service_start.cf | 8 ++++--- .../service_started_path.cf | 3 ++- tree/30_generic_methods/service_stop.cf | 8 ++++--- tree/30_generic_methods/service_stopped.cf | 5 ++-- 17 files changed, 124 insertions(+), 76 deletions(-) diff --git a/tree/20_cfe_basics/ncf_lib.cf b/tree/20_cfe_basics/ncf_lib.cf index d12e24f3d..9d068ea1a 100644 --- a/tree/20_cfe_basics/ncf_lib.cf +++ b/tree/20_cfe_basics/ncf_lib.cf @@ -1173,7 +1173,7 @@ bundle agent ncf_services(service, action) "canonified_action" string => canonify("${action}"); "canonified_action_command" string => canonify("${action_command}"); - "class_prefix" string => "ncf_services_${canonified_service}_${canonified_action}"; + "class_prefix" string => "${report_data.canonified_directive_id}_ncf_services_${canonified_service}_${canonified_action}"; defaults: # status is an alias to is-active (in systemd, it is not the same thing the only difference is the output, which is not kept anyway) @@ -1209,7 +1209,8 @@ bundle agent ncf_services(service, action) # Due to lack of integration between upstart and init scripts, we have to make different cases. "is_upstart_service" not => returnszero("/sbin/initctl status ${service} 2>&1 | ${paths.path[grep]} -E 'Unknown job|Unable to connect to Upstart' > /dev/null", "useshell"), - ifvarclass => "ubuntu.initctl_utility_present"; + ifvarclass => "ubuntu.initctl_utility_present", + comment => "${report_data.directive_id}"; # Due to compatibility issues when mixing init.d/service and systemctl calls, we use the init script when present "is_init_service" expression => fileexists("/etc/init.d/${service}"); @@ -1221,7 +1222,8 @@ bundle agent ncf_services(service, action) # Actual command - for checks on non-windows systems ##### pass1.is_check_action.!windows.!is_process_action.method_found.!(slackware.is_boot_action):: - "action_ok" expression => returnszero("${action_command} 2>&1 > /dev/null", "useshell"); + "action_ok" expression => returnszero("${action_command} 2>&1 > /dev/null", "useshell"), + comment => "${report_data.directive_id}"; any:: "pass3" expression => "pass2"; @@ -1252,7 +1254,8 @@ bundle agent ncf_services(service, action) ifvarclass => "${class_prefix}_checked_ok"; # Slackware boot actions pass2.slackware.is_boot_action:: - "action" usebundle => slackware_boot_services("${service}", "${action}", "${class_prefix}"); + "action" usebundle => slackware_boot_services("${service}", "${action}", "${class_prefix}"), + comment => "${report_data.directive_id}"; processes: ########################################################################### @@ -1279,17 +1282,20 @@ bundle agent ncf_services(service, action) windows.is_valid_action.!is_restart_action:: "${service}" service_policy => "${action}", - classes => classes_generic("${class_prefix}"); + classes => classes_generic("${class_prefix}"), + comment => "${report_data.directive_id}"; windows.is_restart_action:: "${service}" service_policy => "stop", - classes => classes_generic("${class_prefix}_stop_service"); + classes => classes_generic("${class_prefix}_stop_service"), + comment => "${report_data.directive_id}"; "${service}" service_policy => "start", classes => classes_generic("${class_prefix}"), - ifvarclass => "${class_prefix}_stop_service_ok"; + ifvarclass => "${class_prefix}_stop_service_ok", + comment => "${report_data.directive_id}"; commands: ##### @@ -1302,7 +1308,8 @@ bundle agent ncf_services(service, action) pass2.!is_check_action.!windows.!is_process_action.method_found.!(slackware.is_boot_action):: "${action_command}" contain => in_shell_and_silent, - classes => classes_generic("${class_prefix}"); + classes => classes_generic("${class_prefix}"), + comment => "${report_data.directive_id}"; reports: diff --git a/tree/30_generic_methods/command_execution.cf b/tree/30_generic_methods/command_execution.cf index 4a5847c09..e7ba66ab5 100644 --- a/tree/30_generic_methods/command_execution.cf +++ b/tree/30_generic_methods/command_execution.cf @@ -21,7 +21,7 @@ # @action # # @parameter command_name Command name -# +# # @class_prefix command_execution # @class_parameter command_name @@ -31,17 +31,24 @@ bundle agent command_execution(command_name) "old_class_prefix" string => canonify("command_execution_${command_name}"); "args" slist => { "${command_name}" }; "report_param" string => join("_", args); - "full_class_prefix" string => canonify("command_execution_${report_param}"); + "full_class_prefix" string => canonify("${report_data.canonified_directive_id}_command_execution_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); + classes: + "pass2" expression => "pass1"; + "pass1" expression => "any"; methods: + pass2:: "report" usebundle => _log_v3("Execute the command ${command_name}", "${command_name}", "${old_class_prefix}", "${class_prefix}", @{args}), - ifvarclass => "${old_class_prefix}_reached|${class_prefix}_reached"; + ifvarclass => "${old_class_prefix}_reached|${class_prefix}_reached", + comment => "${report_data.directive_id}"; commands: + pass1:: "${command_name}" - contain => in_shell, - classes => classes_generic_two("${old_class_prefix}", "${class_prefix}"); + contain => in_shell, + classes => classes_generic_two("${old_class_prefix}", "${class_prefix}"), + comment => "${report_data.directive_id}"; } diff --git a/tree/30_generic_methods/command_execution_result.cf b/tree/30_generic_methods/command_execution_result.cf index 75621ceb6..69cf99b1c 100644 --- a/tree/30_generic_methods/command_execution_result.cf +++ b/tree/30_generic_methods/command_execution_result.cf @@ -21,13 +21,13 @@ # @action # @documentation Execute a command and create result conditions # depending on the exit codes given in parameters. -# If an exit code is not in the list it will lead to an error status. +# If an exit code is not in the list it will lead to an error status. # If you want 0 to be a success you have to list it in the kept_codes list # # @parameter command The command to run # @parameter kept_codes List of codes that produce a kept status separated with commas (ex: 1,2,5) # @parameter repaired_codes List of codes that produce a repaired status separated with commas (ex: 3,4,6) -# +# # @class_prefix command_execution_result # @class_parameter command @@ -37,19 +37,27 @@ bundle agent command_execution_result(command, kept_codes, repaired_codes) "old_class_prefix" string => canonify("command_execution_result_${command}"); "args" slist => { "${command}", "${kept_codes}", "${repaired_codes}" }; "report_param" string => join("_", args); - "full_class_prefix" string => canonify("command_execution_result_${report_param}"); + "full_class_prefix" string => canonify("${report_data.canonified_directive_id}_command_execution_result_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); "kept_list" slist => splitstring("${kept_codes}", "\s*,\s*", "256"); "repaired_list" slist => splitstring("${repaired_codes}", "\s*,\s*", "256"); + classes: + "pass2" expression => "pass1"; + "pass1" expression => "any"; + methods: + pass2:: "report" usebundle => _log_v3("Execute the command ${command}", "${command}", "${old_class_prefix}", "${class_prefix}", @{args}), - ifvarclass => "${old_class_prefix}_reached|${class_prefix}_reached"; + ifvarclass => "${old_class_prefix}_reached|${class_prefix}_reached", + comment => "${report_data.directive_id}"; commands: + pass1:: "${command}" - contain => in_shell, - classes => classes_generic_return_code_list_two("${old_class_prefix}", "${class_prefix}", @{kept_list}, @{repaired_list}); + contain => in_shell, + classes => classes_generic_return_code_list_two("${old_class_prefix}", "${class_prefix}", @{kept_list}, @{repaired_list}), + comment => "${report_data.directive_id}"; } diff --git a/tree/30_generic_methods/service_action.cf b/tree/30_generic_methods/service_action.cf index 390661967..df1bec175 100644 --- a/tree/30_generic_methods/service_action.cf +++ b/tree/30_generic_methods/service_action.cf @@ -78,7 +78,7 @@ # # @parameter service_name Name of the service # @parameter action Action to trigger on the service (start, stop, restart, reload, ...) -# +# # @class_prefix service_action # @class_parameter service_name @@ -93,10 +93,10 @@ bundle agent service_action(service_name, action) "args" slist => { "${service_name}", "${action}" }; "report_param" string => join("_", args); - "full_class_prefix" string => canonify("service_action_${report_param}"); + "full_class_prefix" string => canonify("${report_data.canonified_directive_id}_service_action_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); - "full_inner_class_prefix" string => canonify("ncf_services_${report_param}"); + "full_inner_class_prefix" string => canonify("${report_data.canonified_directive_id}_ncf_services_${report_param}"); "inner_class_prefix" string => string_head("${full_inner_class_prefix}", "1000"); @@ -107,7 +107,8 @@ bundle agent service_action(service_name, action) "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "action" usebundle => ncf_services("${service_name}", "${action}"); + "action" usebundle => ncf_services("${service_name}", "${action}"), + comment => "${report_data.directive_id}"; "reenable_reporting_${class_prefix}" usebundle => enable_reporting, @@ -117,5 +118,6 @@ bundle agent service_action(service_name, action) "new result classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"), ifvarclass => "${inner_class_prefix}_reached"; - "report" usebundle => _log_v3("Run action ${action} on service ${service_name}", "${service_name}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Run action ${action} on service ${service_name}", "${service_name}", "${old_class_prefix}", "${class_prefix}", @{args}), + comment => "${report_data.directive_id}"; } diff --git a/tree/30_generic_methods/service_check_disabled_at_boot.cf b/tree/30_generic_methods/service_check_disabled_at_boot.cf index 7723c4e8b..e6babf2b1 100644 --- a/tree/30_generic_methods/service_check_disabled_at_boot.cf +++ b/tree/30_generic_methods/service_check_disabled_at_boot.cf @@ -20,7 +20,7 @@ # @description Check if a service is set to not start at boot using the appropriate method # # @parameter service_name Service name (as recognized by systemd, init.d, etc...) -# +# # @class_prefix service_check_disabled_at_boot # @class_parameter service_name # This bundle will define a condition service_check_disabled_at_boot_${service_name}_{kept,ok,not_ok,failed,reached} @@ -37,7 +37,7 @@ bundle agent service_check_disabled_at_boot(service_name) "full_class_prefix" string => canonify("service_check_disabled_at_boot_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); - "full_inner_class_prefix" string => canonify("ncf_services_${report_param}_is_enabled"); + "full_inner_class_prefix" string => canonify("${report_data.canonified_directive_id}_ncf_services_${report_param}_is_enabled"); "inner_class_prefix" string => string_head("${full_inner_class_prefix}", "1000"); @@ -48,21 +48,23 @@ bundle agent service_check_disabled_at_boot(service_name) methods: "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "check_enabled" usebundle => ncf_services("${service_name}", "is-enabled"); + "check_enabled" usebundle => ncf_services("${service_name}", "is-enabled"), + comment => "${report_data.directive_id}"; "reenable_reporting_${class_prefix}" usebundle => enable_reporting, ifvarclass => "should_report"; "success" usebundle => _classes_success("${old_class_prefix}"), - ifvarclass => "ncf_services_${canonified_service_name}_is_enabled_not_ok"; + ifvarclass => "${report_data.canonified_directive_id}_ncf_services_${canonified_service_name}_is_enabled_not_ok"; "success" usebundle => _classes_success("${class_prefix}"), ifvarclass => "${inner_class_prefix}_not_ok"; "failure" usebundle => _classes_failure("${old_class_prefix}"), - ifvarclass => "ncf_services_${canonified_service_name}_is_enabled_ok"; + ifvarclass => "${report_data.canonified_directive_id}_ncf_services_${canonified_service_name}_is_enabled_ok"; "failure" usebundle => _classes_failure("${class_prefix}"), ifvarclass => "${inner_class_prefix}_ok"; - "reports" usebundle => _log_v3("Check if service ${service_name} is disabled at boot", "${service_name}", "${old_class_prefix}", "${class_prefix}", @{args}); + "reports" usebundle => _log_v3("Check if service ${service_name} is disabled at boot", "${service_name}", "${old_class_prefix}", "${class_prefix}", @{args}), + comment => "${report_data.directive_id}"; } diff --git a/tree/30_generic_methods/service_check_running.cf b/tree/30_generic_methods/service_check_running.cf index f8164f633..06a1666d9 100644 --- a/tree/30_generic_methods/service_check_running.cf +++ b/tree/30_generic_methods/service_check_running.cf @@ -20,7 +20,7 @@ # @description Check if a service is running using the appropriate method # # @parameter service_name Process name -# +# # @class_prefix service_check_running # @class_parameter service_name @@ -36,7 +36,7 @@ bundle agent service_check_running(service_name) "full_class_prefix" string => canonify("service_check_running_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); - "full_inner_class_prefix" string => canonify("ncf_services_${report_param}_is_active"); + "full_inner_class_prefix" string => canonify("${report_data.canonified_directive_id}_ncf_services_${report_param}_is_active"); "inner_class_prefix" string => string_head("${full_inner_class_prefix}", "1000"); @@ -47,15 +47,17 @@ bundle agent service_check_running(service_name) methods: "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "check_active" usebundle => ncf_services("${service_name}", "is-active"); + "check_active" usebundle => ncf_services("${service_name}", "is-active"), + comment => "${report_data.directive_id}"; "reenable_reporting_${class_prefix}" usebundle => enable_reporting, ifvarclass => "should_report"; - "class copy" usebundle => _classes_copy("ncf_services_${canonified_service_name}_is_active", "${old_class_prefix}"), - ifvarclass => "ncf_services_${canonified_service_name}_is_active_reached"; + "class copy" usebundle => _classes_copy("${inner_class_prefix}", "${old_class_prefix}"), + ifvarclass => "${inner_class_prefix}_reached"; "new result classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"), ifvarclass => "${inner_class_prefix}_reached"; - "report" usebundle => _log_v3("Check if the service ${service_name} is started", "${service_name}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Check if the service ${service_name} is started", "${service_name}", "${old_class_prefix}", "${class_prefix}", @{args}), + comment => "${report_data.directive_id}"; } diff --git a/tree/30_generic_methods/service_check_running_ps.cf b/tree/30_generic_methods/service_check_running_ps.cf index 97e0265e3..7f2d0f76b 100644 --- a/tree/30_generic_methods/service_check_running_ps.cf +++ b/tree/30_generic_methods/service_check_running_ps.cf @@ -20,7 +20,7 @@ # @description Check if a service is running using ps # # @parameter service_regex Regular expression used to select a process in ps output -# +# # @class_prefix service_check_running # @class_parameter service_regex @@ -36,7 +36,7 @@ bundle agent service_check_running_ps(service_regex) "full_class_prefix" string => canonify("service_check_running_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); - "full_inner_class_prefix" string => canonify("ncf_services_${report_param}_is_active_process"); + "full_inner_class_prefix" string => canonify("${report_data.directive_id}_ncf_services_${report_param}_is_active_process"); "inner_class_prefix" string => string_head("${full_inner_class_prefix}", "1000"); @@ -48,17 +48,19 @@ bundle agent service_check_running_ps(service_regex) methods: "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "check_active" usebundle => ncf_services("${service_regex}", "is-active-process"); + "check_active" usebundle => ncf_services("${service_regex}", "is-active-process"), + comment => "${report_data.directive_id}"; "reenable_reporting_${class_prefix}" usebundle => enable_reporting, ifvarclass => "should_report"; - "class copy" usebundle => _classes_copy("ncf_services_${canonified_service_regex}_is_active_process", "${old_class_prefix}"), - ifvarclass => "ncf_services_${canonified_service_regex}_is_active_process_reached"; + "class copy" usebundle => _classes_copy("${inner_class_prefix}", "${old_class_prefix}"), + ifvarclass => "${inner_class_prefix}_reached"; "new result classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"), ifvarclass => "${inner_class_prefix}_reached"; "report" - usebundle => _log_v3("Check if the service ${service_regex} is started using ps", "${service_regex}", "${old_class_prefix}", "${class_prefix}", @{args}); + usebundle => _log_v3("Check if the service ${service_regex} is started using ps", "${service_regex}", "${old_class_prefix}", "${class_prefix}", @{args}), + comment => "${report_data.directive_id}"; } diff --git a/tree/30_generic_methods/service_check_started_at_boot.cf b/tree/30_generic_methods/service_check_started_at_boot.cf index 157c6fb57..14e28f84f 100644 --- a/tree/30_generic_methods/service_check_started_at_boot.cf +++ b/tree/30_generic_methods/service_check_started_at_boot.cf @@ -37,7 +37,7 @@ bundle agent service_check_started_at_boot(service_name) "full_class_prefix" string => canonify("service_check_started_at_boot_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); - "full_inner_class_prefix" string => canonify("ncf_services_${report_param}_is_enabled"); + "full_inner_class_prefix" string => canonify("${report_data.canonified_directive_id}_ncf_services_${report_param}_is_enabled"); "inner_class_prefix" string => string_head("${full_inner_class_prefix}", "1000"); @@ -48,15 +48,17 @@ bundle agent service_check_started_at_boot(service_name) methods: "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "check_enabled" usebundle => ncf_services("${service_name}", "is-enabled"); + "check_enabled" usebundle => ncf_services("${service_name}", "is-enabled"), + comment => "${report_data.directive_id}"; "reenable_reporting_${class_prefix}" usebundle => enable_reporting, ifvarclass => "should_report"; - "class copy" usebundle => _classes_copy("ncf_services_${canonified_service_name}_is_enabled", "${old_class_prefix}"), - ifvarclass => "ncf_services_${canonified_service_name}_is_enabled_reached"; + "class copy" usebundle => _classes_copy("${inner_class_prefix}", "${old_class_prefix}"), + ifvarclass => "${inner_class_prefix}_reached"; "new result classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"), ifvarclass => "${inner_class_prefix}_reached"; - "reports" usebundle => _log_v3("Check if service ${service_name} is started at boot", "${service_name}", "${old_class_prefix}", "${class_prefix}", @{args}); + "reports" usebundle => _log_v3("Check if service ${service_name} is started at boot", "${service_name}", "${old_class_prefix}", "${class_prefix}", @{args}), + comment => "${report_data.directive_id}"; } diff --git a/tree/30_generic_methods/service_disabled.cf b/tree/30_generic_methods/service_disabled.cf index 05121f5ad..157311bff 100644 --- a/tree/30_generic_methods/service_disabled.cf +++ b/tree/30_generic_methods/service_disabled.cf @@ -40,7 +40,7 @@ bundle agent service_disabled(service_name) "full_class_prefix" string => canonify("service_disabled_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); - "full_inner_class_prefix" string => canonify("ncf_services_${report_param}_disable"); + "full_inner_class_prefix" string => canonify("${report_data.canonified_directive_id}_ncf_services_${report_param}_disable"); "inner_class_prefix" string => string_head("${full_inner_class_prefix}", "1000"); @@ -53,11 +53,13 @@ bundle agent service_disabled(service_name) !windows:: "disable_at_boot" - usebundle => service_check_disabled_at_boot("${service_name}"); + usebundle => service_check_disabled_at_boot("${service_name}"), + comment => "${report_data.directive_id}"; "undefine_at_boot" usebundle => ncf_services("${service_name}", "disable"), - ifvarclass => "service_check_disabled_at_boot_${canonified_service_name}_not_ok"; + ifvarclass => "service_check_disabled_at_boot_${canonified_service_name}_not_ok", + comment => "${report_data.directive_id}"; !windows:: "already undefined" @@ -69,12 +71,12 @@ bundle agent service_disabled(service_name) ifvarclass => "service_check_disabled_at_boot_${canonified_service_name}_ok"; "copy classes" - usebundle => _classes_copy("ncf_services_${canonified_service_name}_disable", "${old_class_prefix}"), + usebundle => _classes_copy("${inner_class_prefix}", "${old_class_prefix}"), ifvarclass => "service_check_disabled_at_boot_${canonified_service_name}_not_ok"; "copy classes" - usebundle => _classes_copy("${inner_class_prefix}_disable", "${class_prefix}"), - ifvarclass => "${inner_class_prefix}_not_ok"; + usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"), + ifvarclass => "service_check_disabled_at_boot_${canonified_service_name}_not_ok"; windows:: "action" usebundle => service_stop("${service_name}"); @@ -89,6 +91,7 @@ bundle agent service_disabled(service_name) usebundle => enable_reporting, ifvarclass => "should_report"; "report" - usebundle => _log_v3("Ensure service ${service_name} is disabled at boot", "${service_name}", "${old_class_prefix}", "${class_prefix}", @{args}); + usebundle => _log_v3("Ensure service ${service_name} is disabled at boot", "${service_name}", "${old_class_prefix}", "${class_prefix}", @{args}), + comment => "${report_data.directive_id}"; } diff --git a/tree/30_generic_methods/service_enabled.cf b/tree/30_generic_methods/service_enabled.cf index 9401ae332..cefe95096 100644 --- a/tree/30_generic_methods/service_enabled.cf +++ b/tree/30_generic_methods/service_enabled.cf @@ -53,11 +53,13 @@ bundle agent service_enabled(service_name) usebundle => disable_reporting; !windows:: "check_at_boot" - usebundle => service_check_started_at_boot("${service_name}"); + usebundle => service_check_started_at_boot("${service_name}"), + comment => "${report_data.directive_id}"; "define_at_boot" usebundle => ncf_services("${service_name}", "enable"), - ifvarclass => "${inner_class_prefix}_not_ok"; + ifvarclass => "${inner_class_prefix}_not_ok", + comment => "${report_data.directive_id}"; !windows:: "already defined" @@ -69,11 +71,11 @@ bundle agent service_enabled(service_name) ifvarclass => "${inner_class_prefix}_ok"; "copy classes" - usebundle => _classes_copy("ncf_services_${canonified_service_name}_enable", "${old_class_prefix}"), + usebundle => _classes_copy("${report_data.canonified_directive_id}_ncf_services_${canonified_service_name}_enable", "${old_class_prefix}"), ifvarclass => "${inner_class_prefix}_not_ok"; "copy classes" - usebundle => _classes_copy("ncf_services_${canonified_service_name}_enable", "${class_prefix}"), + usebundle => _classes_copy("${report_data.canonified.directive_id}_ncf_services_${canonified_service_name}_enable", "${class_prefix}"), ifvarclass => "${inner_class_prefix}_not_ok"; windows:: @@ -89,6 +91,7 @@ bundle agent service_enabled(service_name) usebundle => enable_reporting, ifvarclass => "should_report"; "report" - usebundle => _log_v3("Ensure service ${service_name} is started at boot", "${service_name}", "${old_class_prefix}", "${class_prefix}", @{args}); + usebundle => _log_v3("Ensure service ${service_name} is started at boot", "${service_name}", "${old_class_prefix}", "${class_prefix}", @{args}), + comment => "${report_data.directive_id}"; } diff --git a/tree/30_generic_methods/service_ensure_running_path.cf b/tree/30_generic_methods/service_ensure_running_path.cf index a357844c1..c20b33332 100644 --- a/tree/30_generic_methods/service_ensure_running_path.cf +++ b/tree/30_generic_methods/service_ensure_running_path.cf @@ -62,7 +62,8 @@ bundle agent service_ensure_running_path(service_name, service_path) "new result classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"), ifvarclass => "${inner_class_prefix}_reached"; "report" - usebundle => _log_v3("Ensure that service ${service_name} is running", "${service_name}", "${old_class_prefix}", "${class_prefix}", @{args}); + usebundle => _log_v3("Ensure that service ${service_name} is running", "${service_name}", "${old_class_prefix}", "${class_prefix}", @{args}), + comment => "${report_data.directive_id}"; } diff --git a/tree/30_generic_methods/service_restart.cf b/tree/30_generic_methods/service_restart.cf index 583a14fe4..a65d289ef 100644 --- a/tree/30_generic_methods/service_restart.cf +++ b/tree/30_generic_methods/service_restart.cf @@ -35,7 +35,7 @@ bundle agent service_restart(service_name) "full_class_prefix" string => canonify("service_restart_${service_name}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); - "full_inner_class_prefix" string => canonify("service_action_${service_name}_restart"); + "full_inner_class_prefix" string => canonify("${report_data.canonified_directive_id}_service_action_${service_name}_restart"); "inner_class_prefix" string => string_head("${full_inner_class_prefix}", "1000"); classes: @@ -52,5 +52,6 @@ bundle agent service_restart(service_name) # old_class_prefix in service_restart_if is the same as in service_restart "new result classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"); - "report" usebundle => _log_v3("Restart service ${service_name}", "${service_name}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Restart service ${service_name}", "${service_name}", "${old_class_prefix}", "${class_prefix}", @{args}), + comment => "${report_data.directive_id}"; } diff --git a/tree/30_generic_methods/service_restart_if.cf b/tree/30_generic_methods/service_restart_if.cf index 1d329575a..9c94cb544 100644 --- a/tree/30_generic_methods/service_restart_if.cf +++ b/tree/30_generic_methods/service_restart_if.cf @@ -23,7 +23,7 @@ # # @parameter service_name Name of the service # @parameter trigger_class class(es) which will trigger the restart of Service "(package_service_installed|service_conf_changed)" by example -# +# # @class_prefix service_restart # @class_parameter service_name @@ -38,10 +38,10 @@ bundle agent service_restart_if(service_name, trigger_class) "args" slist => { "${service_name}", "${trigger_class}" }; "report_param" string => join("_", args); - "full_class_prefix" string => canonify("service_restart_${report_param}"); + "full_class_prefix" string => canonify("${report_data.canonified_directive_id}_service_restart_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); - "full_inner_class_prefix" string => canonify("service_action_${service_name}_restart"); + "full_inner_class_prefix" string => canonify("${report_data.canonified_directive_id}_service_action_${service_name}_restart"); "inner_class_prefix" string => string_head("${full_inner_class_prefix}", "1000"); classes: @@ -60,7 +60,8 @@ bundle agent service_restart_if(service_name, trigger_class) ifvarclass => "!(${trigger_class})"; "restart" usebundle => service_action("${service_name}", "restart"), - ifvarclass => "${trigger_class}"; + ifvarclass => "${trigger_class}", + comment => "${report_data.directive_id}"; "class copy" usebundle => _classes_copy("${inner_class_prefix}", "${old_class_prefix}"), ifvarclass => "${trigger_class}"; @@ -72,5 +73,6 @@ bundle agent service_restart_if(service_name, trigger_class) usebundle => enable_reporting, ifvarclass => "should_report"; - "report" usebundle => _log_v3("Restart service ${canonified_service_name} if '${trigger_class}' condition defined", "${service_name}", "service_restart_${canonified_service_name}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Restart service ${canonified_service_name} if '${trigger_class}' condition defined", "${service_name}", "service_restart_${canonified_service_name}", "${class_prefix}", @{args}), + comment => "${report_data.directive_id}"; } diff --git a/tree/30_generic_methods/service_start.cf b/tree/30_generic_methods/service_start.cf index c6eb95845..12ecf5eff 100644 --- a/tree/30_generic_methods/service_start.cf +++ b/tree/30_generic_methods/service_start.cf @@ -41,7 +41,7 @@ bundle agent service_start(service_name) "full_class_prefix" string => canonify("service_start_${service_name}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); - "full_inner_class_prefix" string => canonify("service_action_${service_name}_start"); + "full_inner_class_prefix" string => canonify("${report_data.canonified_directive_id}_service_action_${service_name}_start"); "inner_class_prefix" string => string_head("${full_inner_class_prefix}", "1000"); @@ -52,7 +52,8 @@ bundle agent service_start(service_name) "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "start" usebundle => service_action("${service_name}", "start"); + "start" usebundle => service_action("${service_name}", "start"), + comment => "${report_data.directive_id}"; "reenable_reporting_${class_prefix}" usebundle => enable_reporting, @@ -62,6 +63,7 @@ bundle agent service_start(service_name) "class copy" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"); - "report" usebundle => _log_v3("Start service ${service_name}", "${service_name}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Start service ${service_name}", "${service_name}", "${old_class_prefix}", "${class_prefix}", @{args}), + comment => "${report_data.directive_id}"; } diff --git a/tree/30_generic_methods/service_started_path.cf b/tree/30_generic_methods/service_started_path.cf index 48ff4e8a1..be518a5da 100644 --- a/tree/30_generic_methods/service_started_path.cf +++ b/tree/30_generic_methods/service_started_path.cf @@ -88,6 +88,7 @@ bundle agent service_started_path(service_name, service_path) usebundle => enable_reporting, ifvarclass => "should_report"; "report" - usebundle => _log_v3("Ensure that service ${service_name} is running", "${service_name}", "${old_class_prefix}", "${class_prefix}", @{args}); + usebundle => _log_v3("Ensure that service ${service_name} is running", "${service_name}", "${old_class_prefix}", "${class_prefix}", @{args}), + comment => "${report_data.directive_id}"; } diff --git a/tree/30_generic_methods/service_stop.cf b/tree/30_generic_methods/service_stop.cf index 2c55677e1..5cc7d6e46 100644 --- a/tree/30_generic_methods/service_stop.cf +++ b/tree/30_generic_methods/service_stop.cf @@ -41,7 +41,7 @@ bundle agent service_stop(service_name) "full_class_prefix" string => canonify("service_stop_${service_name}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); - "full_inner_class_prefix" string => canonify("service_action_${service_name}_stop"); + "full_inner_class_prefix" string => canonify("${report_data.canonified_directive_id}_service_action_${service_name}_stop"); "inner_class_prefix" string => string_head("${full_inner_class_prefix}", "1000"); classes: @@ -51,7 +51,8 @@ bundle agent service_stop(service_name) "disable_reporting_${class_prefix}" usebundle => disable_reporting; - "stop" usebundle => service_action("${service_name}", "stop"); + "stop" usebundle => service_action("${service_name}", "stop"), + comment => "${report_data.directive_id}"; "reenable_reporting_${class_prefix}" usebundle => enable_reporting, @@ -61,6 +62,7 @@ bundle agent service_stop(service_name) "class copy" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}"); - "report" usebundle => _log_v3("Stop service ${service_name}", "${service_name}", "${old_class_prefix}", "${class_prefix}", @{args}); + "report" usebundle => _log_v3("Stop service ${service_name}", "${service_name}", "${old_class_prefix}", "${class_prefix}", @{args}), + comment => "${report_data.directive_id}"; } diff --git a/tree/30_generic_methods/service_stopped.cf b/tree/30_generic_methods/service_stopped.cf index 83d9b7dc7..cd5e9879b 100644 --- a/tree/30_generic_methods/service_stopped.cf +++ b/tree/30_generic_methods/service_stopped.cf @@ -20,7 +20,7 @@ # @description Ensure that a service is stopped using the appropriate method # # @parameter service_name Service -# +# # @class_prefix service_stopped # @class_parameter service_name @@ -89,6 +89,7 @@ bundle agent service_stopped(service_name) usebundle => enable_reporting, ifvarclass => "should_report"; "report" - usebundle => _log_v3("Ensure that service ${service_name} is stopped", "${service_name}", "${old_class_prefix}", "${class_prefix}", @{args}); + usebundle => _log_v3("Ensure that service ${service_name} is stopped", "${service_name}", "${old_class_prefix}", "${class_prefix}", @{args}), + comment => "${report_data.directive_id}"; }