Skip to content

Instantly share code, notes, and snippets.

View zzamboni's full-sized avatar
:octocat:

Diego Zamboni zzamboni

:octocat:
View GitHub Profile
body common control
{
bundlesequence => { "globals" };
}
bundle agent foo(name)
{
vars:
"var_$(name)" string => "Hi $(name)";
reports:
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:
@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");
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";
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
@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",
@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 / test-sections.cf
Created November 25, 2013 23:56
Update/add <Directory> sections in an Apache config file.
body common control
{
bundlesequence => { "test" };
inputs => {
"lib/3.5/common.cf",
"lib/3.5/files.cf",
};
}
bundle agent test
@zzamboni
zzamboni / keybase.md
Created September 23, 2014 16:45
keybase.md

Keybase proof

I hereby claim:

  • I am zzamboni on github.
  • I am zzamboni (https://keybase.io/zzamboni) on keybase.
  • I have a public key whose fingerprint is 51EB CE05 779A 911D E67F F996 DAD7 2863 376A A4F6

To claim this, I am signing this object:

#first make sure go, git and mercurial are installed.
if [[ -z $(which git) ]]; then
echo "Git must be installed"
exit 1
fi
if [[ -z $(which hg) ]]; then
echo "mercurial must be installed"
exit 1
fi