Table of Contents
update.cf
Table of Contents
$(sys.inputdir)/update.cf
is responsible for updating
policy from the hub as well as ensuring various core
cfenigne components are running.
common bodies
cfengine_update_controls
Prototype: cfengine_update_controls
Implementation:
bundle common cfengine_update_controls
{
vars:
# 3.6 uses the split controls
cfengine_3_6::
"update_def_inputs"
slist => {
"controls/$(sys.cf_version_major).$(sys.cf_version_minor)/update_def.cf",
"controls/$(sys.cf_version_major).$(sys.cf_version_minor)/update_def_inputs.cf",
};
# 3.7+ uses the re-unified controls
!cfengine_3_6::
"update_def_inputs"
slist => {
"controls/update_def.cf",
"controls/update_def_inputs.cf",
};
reports:
DEBUG|DEBUG_cfengine_update_controls::
"DEBUG $(this.bundle): update def inputs='$(update_def_inputs)'";
}
agent bundles
cfengine_internal_standalone_self_upgrade
Prototype: cfengine_internal_standalone_self_upgrade
Description: Manage the version of CFEngine that is currently installed. This policy executes a stand alone policy as a sub agent. If systemd is found we assume that it is necessary to escape the current unit via systemd-run.
Implementation:
bundle agent cfengine_internal_standalone_self_upgrade
{
vars:
"exec_prefix"
string => ifelse( isexecutable("/bin/systemd-run"), "/bin/systemd-run --unit=cfengine-upgrade --scope ",
isexecutable( "/usr/bin/systemd-run" ), "/usr/bin/systemd-run --unit=cfengine-upgrade --scope ", ""); # trailing space in commmands important
commands:
trigger_upgrade::
"$(exec_prefix)$(sys.cf_agent)"
handle => "standalone_self_upgrade",
args => "--inform --timestamp --file $(this.promise_dirname)/standalone_self_upgrade.cf --define trigger_upgrade,update_cf_initiated";
}
common bodies
control
Prototype: control
Implementation:
body common control
{
bundlesequence => {
"update_def",
"u_cfengine_enterprise",
@(u_cfengine_enterprise.def),
"cfe_internal_dc_workflow",
"cfe_internal_update_policy",
"cfengine_internal_standalone_self_upgrade",
"cfe_internal_update_processes",
};
version => "update.cf $(update_def.current_version)";
inputs => {
"cfe_internal/update/lib.cf",
"cfe_internal/update/systemd_units.cf",
@(cfengine_update_controls.update_def_inputs),
"cfe_internal/update/cfe_internal_dc_workflow.cf",
"cfe_internal/update/cfe_internal_local_git_remote.cf",
"cfe_internal/update/cfe_internal_update_from_repository.cf",
"cfe_internal/update/update_policy.cf",
"cfe_internal/update/update_processes.cf"
};
}
agent bodies
control
Prototype: control
Implementation:
body agent control
{
ifelapsed => "1";
skipidentify => "true";
}
classes bodies
u_kept_successful_command
Prototype: u_kept_successful_command
Description: Set command to "kept" instead of "repaired" if it returns 0
Implementation:
body classes u_kept_successful_command
{
kept_returncodes => { "0" };
failed_returncodes => { "1" };
}