Skip to content

Instantly share code, notes, and snippets.

View rpetre's full-sized avatar

Petru Rațiu rpetre

  • RLUG
  • București, România
View GitHub Profile
@rpetre
rpetre / gist:3208756
Created July 30, 2012 18:06
this seems to work properly
body common control {
bundlesequence => { "update" };
}
bundle common g {
vars:
"sandbox_lockfile" string => "/var/cfengine/sandbox";
has_branch.cf_test::
"message" string => "I am a test machine";
has_branch.cf_prod.!cf_test::
@rpetre
rpetre / gist:3208355
Created July 30, 2012 16:58
trick to switch and remember policies with -D cf_test and -D cf_prod
body common control {
bundlesequence => { "update" };
}
bundle common g {
vars:
"sandbox_lockfile" string => "/var/cfengine/sandbox";
classes:
"cf_test" expression => fileexists("$(sandbox_lockfile)");
body common control {
bundlesequence => { "test" };
}
bundle agent test {
vars:
any::
"list" slist => getindices("hash");
"megalist" slist => { "@(list)" }, policy => "ifdefined";
val1::
@rpetre
rpetre / gist:2368955
Created April 12, 2012 16:39
cfengine 3 test to do version comparison
body common control {
bundlesequence => { "test" };
}
bundle agent version {
vars:
"versionlist" slist => splitstring($(sys.cf_version), "\.", 3);
"canonized" string => join( "", "versionlist");
}
== Rules ==
On Infrastructure
-----------------
There is one system, not a collection of systems.
The desired state of the system should be a known quantity.
The "known quantity" must be machine parseable.
The actual state of the system must self-correct to the desired state.
The only authoritative source for the actual state of the system is the system.
The entire system must be deployable using source media and text files.