Skip to content

Commit 5d1a01f

Browse files
committed
Added service states "active" and "inactive" for systemd
This change brings understanding of "active" and "inactive" states for services when managed by systemd. An "active" service state means the service should be running. An "inactive" service state means the service should not be running. NOTE: When "active" or "inactive" service states are used, no promises about a services state on boot are made. Ticket: ENT-6074 Changelog: Title
1 parent 603f8d7 commit 5d1a01f

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

lib/services.cf

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ bundle agent standard_services(service,state)
8282
# @brief Standard services bundle, used by CFEngine by default
8383
# @author CFEngine AS
8484
# @param service Name of service to control
85-
# @param state The desired state for that service: "start", "restart", "reload", "stop", or "disable". "enable", "enabled", and "disabled" are also able to be used when systemd is detected.
85+
# @param state The desired state for that service: "start", "restart", "reload", "stop", or "disable". "enable", "enabled", and "disabled" are also able to be used when systemd is detected. "active" and "inactive" states are supported for systemd managed hosts and can be used for controlling the services currently running state, but make no promises about the service state on boot.
8686
#
8787
# This bundle is used by CFEngine if you don't specify a services
8888
# handler explicitly, and will work with systemd or chkconfig or other
@@ -208,10 +208,12 @@ bundle agent standard_services(service,state)
208208
"request_disabled" expression => strcmp("disabled", "$(state)");
209209
"request_enable" expression => strcmp("enable", "$(state)");
210210
"request_enabled" expression => strcmp("enabled", "$(state)");
211+
"request_active" expression => strcmp("active", "$(state)");
212+
"request_inactive" expression => strcmp("inactive", "$(state)");
211213

212-
"action_custom" expression => "!(request_start|request_stop|request_reload|request_restart|request_disable|request_disabled|request_enable|request_enabled)";
213-
"action_start" expression => "request_start.!service_active.can_start_service";
214-
"action_stop" expression => "request_stop.service_active.can_stop_service";
214+
"action_custom" expression => "!(request_start|request_stop|request_reload|request_restart|request_disable|request_disabled|request_enable|request_enabled|request_active|request_inactive)";
215+
"action_start" expression => "(request_start|request_active).!service_active.can_start_service";
216+
"action_stop" expression => "(request_stop|request_inactive).service_active.can_stop_service";
215217
"action_reload" expression => "request_reload.service_active.can_reload_service";
216218
"action_restart" or => {
217219
"request_restart",

0 commit comments

Comments
 (0)