Forum: CFEngine Help
Subject: Re: CFEngine Help: How-to restart machine after certain package have
been installed.
Author: juriskrumins
Link to topic: https://cfengine.com/forum/read.php?3,26673,26704#msg-26704
Actually "rebooting all the time" issue I've also experienced.
In my case it was caused by incorrect class_expression usage (specifically
logical operator usage).
Anyway I've tried following code and seems like it's working:
body common control {
bundlesequence => {"machine_type","packages"};
inputs => {
"cfengine_stdlib.cf",
"machine_type.cf",
"packages.cf"
};
}
bundle common machine_type {
vars:
"hn" slist => { "/root/vz_hardware_node" };
"ct" slist => { "/root/vz_container" };
classes:
"vz_hardware_node" expression=> filesexist ("@(hn)");
"vz_container" expression=> filesexist ("@(ct)");
reports:
vz_hardware_node::
"vz_hardware_node class defined";
vz_container::
"vz_container class defined";
}
bundle agent packages {
vars:
!vz_hardware_node.!vz_container::
"kernel_package" slist => {
"mc",
},
comment => "Define kernel to install arch specifi",
handle => "packages_vars_kernel_package";
packages:
!vz_hardware_node.!vz_container::
"$(packages.kernel_package)"
package_policy => "add",
package_architectures => { "x86_64" },
package_method => yum,
classes => if_repaired("restart_machine");
#reports:
commands:
"/sbin/shutdown -r +5"
ifvarclass => "restart_machine";
}
Just a single issue I've found while experimenting -
package_list_update_ifelapsed="240" by default.
So as fas as I understand package list cache by default (ar least for
package_method=yum) set to 4h,
so altering package list outside of cfengine (maybe even using cfengine
packages promise) can cause
a latency in reaction (package add/delete/update) from CFEngine side mainly
because of outdated
package list cache. So when I run mentioned code frequently
package_list_update_ifelapsed come into play
and code doesn't work as it should, independently of mc package status. Setting
package_list_update_ifelapsed=0
fix this issue, but probably produce more load on system.
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine