Forum: Cfengine Help
Subject: Re: Linux: Restart service
Author: babudro
Link to topic: https://cfengine.com/forum/read.php?3,18802,18804#msg-18804
Hello Michael.
I use the promise_repaired clause to detect if anything changed and, if so, the
"commands:sendmail_fixed::" section takes effect. The basic method I follow is
to find a pre-existing class (e.g., "time of day") that meets my criteria or
set a class based on arbitrary criteria (e.g., does a file exist?) and then use
that class setting to restart the service if it is "true".
Here is an example of how I am maintaining my Sendmail configuration file and
re-starting the service:
bundle agent sendmail {
files:
linux::
"/etc/mail/sendmail.mc"
comment => "Maintain /etc/mail/sendmail.mc",
create => "true",
edit_line => sendmail_mc,
edit_defaults => empty,
perms => mog("644", "root", "root"),
classes => define_class("sendmail_fixed", "sendmail_failed");
commands:
sendmail_fixed::
"/etc/init.d/sendmail restart";
}
body classes define_class(if,else) {
promise_repaired => { "$(if)" };
repair_failed => { "$(else)" };
persist_time => "0";
}
I hope this is helpful.
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine