Forum: Cfengine Help
Subject: Update /etc/motd with timestamp of policy update
Author: [email protected]
Link to topic: https://cfengine.com/forum/read.php?3,19374,19374#msg-19374
I thought it would be helpful to update /etc/motd with the datestamp of the
last policy update. I think its working as I expect, anyway in case someone
else finds it useful.
#### templates/motd.tpl ####
#
# This server is managed by CFengine, any manual edits may be reverted.
# CFengine policy last updated: $(sys.date).
#
-----------------------------------------------------------------------------------------------------------
#### failsafe.cf ####
body common control{
bundlesequence => { "update" };
inputs => { "update.cf" };
}
body depth_search recurse(d){
depth => "$(d)";
}
body edit_defaults empty{
empty_file_before_editing => "true";
edit_backup => "false";
max_file_size => "300000";
}
bundle edit_line expand_template(templatefile){
# Read in the named text file and expand $(var)
# inside the file
insert_lines:
"$(templatefile)"
insert_type => "file",
comment => "Expand variables in the template file",
expand_scalars => "true";
}
-----------------------------------------------------------------------------------------------------------
#### update.cf ####
bundle agent update {
vars:
"policyhost" string => "192.168.1.129";
files:
any::
"/var/cfengine/inputs/"
copy_from =>
update_policy("/var/cfengine/masterfiles","$(policyhost)"),
classes => policy_updated("policy_updated"),
depth_search => recurse("inf");
policy_updated::
"/etc/motd"
comment => "Update /etc/issue with last policy update
time",
create => "true",
edit_defaults => empty,
edit_line =>
expand_template("/var/cfengine/inputs/templates/motd.tpl");
}
body copy_from update_policy(from,server){
servers => { "$(server)" };
source => "$(from)";
purge => "true";
preserve => "true";
compare => "digest";
}
body classes policy_updated(new_class){
promise_kept => { "$(new_class)" };
promise_repaired => { "$(new_class)" };
}
-----------------------------------------------------------------------------------------------------------
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine