Skip to content

Instantly share code, notes, and snippets.

@nickanderson
Created March 1, 2012 02:41
Show Gist options
  • Save nickanderson/1946826 to your computer and use it in GitHub Desktop.
Save nickanderson/1946826 to your computer and use it in GitHub Desktop.
body common control {
bundlesequence => {
"main",
};
inputs => {
"cfengine_stdlib.cf",
};
}
bundle agent main {
vars:
"list" slist => { "1", "2", "3" };
methods:
"any" usebundle => test("@(main.list)");
}
bundle agent test(l) {
files:
"/tmp/testfile"
create => "true",
edit_line => append_if_no_lines("@(test.l)"),
comment => "add the lines we want to the file";
"/tmp/testfile"
edit_line => delete_lines_not_matching("@(test.l)"),
comment => "delete lines that arent in our list";
}
bundle edit_line delete_lines_not_matching(list) {
delete_lines:
"!$(list).*"
comment => "Delete lines do not match our ips or are not comments";
reports:
cfengine::
"$(list)";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment