Skip to content

Instantly share code, notes, and snippets.

@nickanderson
nickanderson / output
Created March 19, 2012 19:04
Difference between append_if_no_line and append_if_no_line
cmdln@ThinkPad-W520:~/.cfagent/inputs$ cf-agent -KIf ./test_append_lines.cf
-> Created file /tmp/test1, mode = 600
-> Edited file /tmp/test1
-> Created file /tmp/test2, mode = 600
-> Edited file /tmp/test2
-> Edited file /tmp/test2
-> Edited file /tmp/test2
cmdln@ThinkPad-W520:~/.cfagent/inputs$ cat /tmp/test1
L1i1
L1i2
@nickanderson
nickanderson / test_override1.cf
Created April 3, 2012 15:13
Odd behavior with overriding bundle paramaterized values
cf-agent -KIf test_override2.cf
R: conf[_motd_file]: /etc/motd
R: conf[_custom_content_file]: /etc/motd.custom
R: conf[_motd_template_file]: /etc/motd_template.txt
@nickanderson
nickanderson / gusto_repair_sudoers.cf
Created April 11, 2012 15:27
Example for _gusto_
body common control {
bundlesequence => {
"main",
};
inputs => {
"cfengine_stdlib.cf",
};
}
R: test1 conf[value1]: overriden value1
R: test1 conf[value2]: default value2
R: test2 conf[value1]: default value1
R: test2 conf[value2]: default value2
body classes if_repaired_kept(repaired, kept){
promise_repaired => { "$(repaired)" };
promise_kept => { "$(kept)" };
}
#!/usr/local/sbin/cf-agent -KIf
body common control {
bundlesequence => {
"main",
};
}
bundle agent main {
body common control {
bundlesequence => {
"main",
};
inputs => {
"cfengine_stdlib.cf",
};
}
body common control {
bundlesequence => {
"main",
};
inputs => {
"cfengine_stdlib.cf",
};
}
bundle edit_line set_variable_values2(file,v)
#
# Another implementation of set_variable_values.
# The input and output should be exactly the same (except the file name),
# but in some Cfengine versions there are bugs,
# so this bundle can be used as a workaround.
#
{
vars:
bundle agent local_user_management_add_users_fileedit (users) {
# Expects to be passed a two-dimensional array keyed on username and field
# The following fields are required.
# gecos, uid, gid, home, shell, passwdhash
# Dependancies: replace_or_add from copbl svn 105 or greater, perl
# Example Usage:
# vars:
# "users[testuser][gecos]" string => "My Test User";
# "users[testuser][uid]" string => "1500";
# "users[testuser][gid]" string => "1500";