Skip to content

Instantly share code, notes, and snippets.

@daebenji
Forked from zzamboni/changes-to-update.cf
Created June 29, 2018 10:45
Show Gist options
  • Save daebenji/a45f235e671cc8a78fe03316e82d1e87 to your computer and use it in GitHub Desktop.
Save daebenji/a45f235e671cc8a78fe03316e82d1e87 to your computer and use it in GitHub Desktop.
How to automatically update /var/cfengine/masterfiles on a CFEngine policy hub from a Subversion or Git repository.
# These go in update.cf (in CFEngine community) or update_policy.cf (in CFEngine Enterprise).
# Once these are in place, you need to manually check out /var/cfengine/masterfiles from the appropriate repository.
# From then on, "svn up" will be run on it periodically to keep it up to date with respect to the repository.
# This needs to be added to the classes: section of the update bundle
# Change .svn to .git to use git.
classes:
"masterfiles_in_svn"
expression => fileexists("$(master_location)/.svn"),
comment => "Check if $(master_location) is checked out from subversion",
handle => "cfe_internal_update_policy_classes_masterfiles_in_svn";
# This needs to be added to the commands: section of the update bundle
# Again, modify the commands accordingly if using git
am_policy_hub.masterfiles_in_svn::
"/usr/bin/svn up"
contain => u_silent_in_dir("$(master_location)"),
action => u_ifelapsed("1"),
comment => "Update masterfiles from svn repository",
handle => "cfe_internal_update_masterfiles_from_svn";
# You need to add u_silent_in_dir and u_ifelapsed at the end of the update.cf file
#########################################################
body contain u_silent_in_dir(s)
{
chdir => "$(s)";
no_output => "true";
}
#########################################################
body action u_ifelapsed(x)
{
ifelapsed => "$(x)";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment