Skip to content

Instantly share code, notes, and snippets.

@zzamboni
Created January 31, 2013 00:15
Show Gist options
  • Save zzamboni/4678668 to your computer and use it in GitHub Desktop.
Save zzamboni/4678668 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