Skip to content

Instantly share code, notes, and snippets.

@nickanderson
Last active August 29, 2015 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickanderson/a46fdf764da3370e2bce to your computer and use it in GitHub Desktop.
Save nickanderson/a46fdf764da3370e2bce to your computer and use it in GitHub Desktop.
CFEngine maintenance policy for freenas 9.3 to keep django running
bundle agent freenas
{
meta:
"tags" slist => { "autorun" };
services:
"django"
service_policy => "start",
service_method => freebsd_service;
}
body service_method freebsd_service
{
service_bundle => freebsd_service_method($(this.promiser), $(this.service_policy));
}
bundle agent freebsd_service_method(service, state)
{
vars:
"c_service" string => canonify($(service));
classes:
"$(c_service)_running" expression => returnszero("/usr/sbin/service $(service) status > /dev/null 2>&1", useshell);
"$(c_service)_desired_running" expression => strcmp($(state), "start");
commands:
"/usr/sbin/service"
args => "$(service) start",
ifvarclass => and(not("$(c_service)_running)"), "$(c_service)_desired_running");
reports:
DEBUG|DEBUG_freebsd_service::
"DEBUG $(this.bundle): $(service) [ RUNNING ]"
ifvarclass => "$(c_service)_running";
"DEBUG $(this.bundle): $(service) [ NOT RUNNING ]"
ifvarclass => not("$(c_service)_running");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment