Forum: CFEngine Help
Subject: cf_null issue
Author: jonesy1234
Link to topic: https://cfengine.com/forum/read.php?3,24205,24205#msg-24205
I'm working on a policy for global & local cron entries. I know it's easier to
manage the whole file but I can't in this instance. The objective is to have
global entries across all hosts, then if a specific entry is need for a host,
define it in an slist named local_root_cron_entries_to_add
Here is the policy:-
########################################################
body common control
{
any::
bundlesequence => {
manage_cron
};
inputs => {
"/tmp/cfengine_stdlib.cf"
};
}
########################################################
bundle agent manage_cron {
vars:
"global_root_cron_entries_to_add" slist => {
"0 0 * * 6 /usr/local/bin/do_savevg.sh
> /dev/null 2>&1"
};
any::
"all_entries_to_be_added" slist => {
"@(global_root_cron_entries_to_add)",
"@(local_root_cron_entries_to_add)",
}, policy => "ifdefined";
"all_entries_to_be_removed" slist => {
"@(global_root_cron_entries_to_remove)",
"@(local_root_cron_entries_to_remove)",
}, policy => "ifdefined";
files:
# root crontab location defined in vars above
"/tmp/root_cron"
comment => "Manage the contents of root cron ",
handle => "root_cron_entries",
create => "true",
classes => if_repaired("root_cron_repaired"),
edit_line =>
append_if_no_lines_and_delete("@{manage_cron.all_entries_to_be_added}","@{manage_cron.all_entries_to_be_removed}");
#commands:
# root_cron_repaired::
# "/usr/bin/crontab $(crontab)";
}
bundle edit_line append_if_no_lines_and_delete(lines_to_add,lines_to_delete)
{
insert_lines:
"$(lines_to_add)"
comment => "Append lines to the file if they don't already
exist";
delete_lines:
".*$(lines_to_delete).*"
comment => "Append lines to the file if they don't already
exist";
}
I'm getting the following in my file:-
root@****:/tmp # cat root_cron
0 0 * * 6 /usr/local/bin/do_savevg.sh > /dev/null 2>&1
cf_null
Shouldn't the cf_null entry be removed as I have the ifdefined statement? I'm
using version 3.2.3.
Cheers
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine