Skip to content

Instantly share code, notes, and snippets.

View zzamboni's full-sized avatar
:octocat:

Diego Zamboni zzamboni

:octocat:
View GitHub Profile
@zzamboni
zzamboni / gist:6601506
Created September 17, 2013 22:23
Build log for cfengine-3.5.2 formula on OS X 10.8.4
$ brew install -v cfengine
==> Downloading http://cfengine.com/source-code/download?file=cfengine-3.5.2.tar.gz
Already downloaded: /Library/Caches/Homebrew/cfengine-3.5.2.tar.gz
tar xf /Library/Caches/Homebrew/cfengine-3.5.2.tar.gz
==> Patching
/usr/bin/patch -f -p1 -i 000-homebrew.diff
patching file cf-agent/verify_environments.c
patching file cf-agent/verify_files_utils.c
==> ./configure --disable-dependency-tracking --prefix=/usr/local/Cellar/cfengine/3.5.2 --with-workdir=/usr/local/var/cfengine --with-tokyocabinet
./configure --disable-dependency-tracking --prefix=/usr/local/Cellar/cfengine/3.5.2 --with-workdir=/usr/local/var/cfengine --with-tokyocabinet
@zzamboni
zzamboni / changes-to-update.cf
Created January 31, 2013 00:15
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",
enterprise> ...........................................................................
enterprise> * Hailing 10.39.118.40 : 5308
enterprise> ...........................................................................
enterprise> Existing connection to 10.39.118.40 seems to be active...
enterprise> Set cfengine port number to 5308 = 5308
enterprise> Set connection timeout to 30
enterprise> -> Connect to 10.39.118.40 = 10.39.118.40 on port 5308
enterprise> -> Selecting FIPS compliant encryption option
enterprise> .....................[.h.a.i.l.].................................
enterprise> Strong authentication of server=10.39.118.40 connection confirmed
vars:
"dir" string => "/etc/apache2/modules-enabled";
"index" slist => getindices("array");
"cindex[$(index)]" string => canonify("$(index)");
"files" slist => lsdir("$(dir)", ".*", "false");
classes:
"should_exist_$(cindex[$(index)])" expression => "any";
files:
"/$(dir)/$(index)"
create => "true";
@zzamboni
zzamboni / arguments1.cf
Created May 5, 2012 20:35
Code examples from CFEngine Tip #002: How to pass arguments to bundles using arrays: http://blog.cf-learn.info/cfengine-tip-002-how-to-pass-arguments-to-bun
bundle agent configfiles
{
vars:
# SSHD configuration to set
"sshd[Protocol]" string => "2";
"sshd[X11Forwarding]" string => "yes";
"sshd[UseDNS]" string => "no";
methods:
"sshd" usebundle => edit_sshd("configfiles.sshd");
bundle agent configfiles
{
vars:
# Files to edit
"files[sysctlconf]" string => "/etc/sysctl.conf";
"files[sshdconfig]" string => "/etc/ssh/sshd_config";
"files[inittab]" string => "/etc/inittab";
# ...
methods:
body common control
{
bundlesequence => { "globals" };
}
bundle agent foo(name)
{
vars:
"var_$(name)" string => "Hi $(name)";
reports:
7.4.9 edit_template
Type: string
Allowed input range: "?(/.*)
Synopsis: The name of a special CFEngine template file to expand
Example:
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by configure, which was
generated by GNU Autoconf 2.61. Invocation command line was
$ ./configure --enable-maintainer-mode --with-tokyocabinet
## --------- ##
## Platform. ##
vars:
"allparams" slist => getindices("$(params)");
secondpass::
"sshdparamlist" slist => grep("[^_].*", "allparams");
"sshdparams[$(sshdparamlist)]" string => "$($(params)[$(sshdparamlist)])";
classes:
"use_restart_cmd" not => strcmp("$($(params)[_sshd_restart_cmd])", "");
"secondpass" expression => isvariable("allparams");
"thirdpass" expression => isvariable("sshdparamlist");