Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 11 additions & 20 deletions content/examples/example-snippets/back_references_in_filenames.cf
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,29 @@
# File editing - back reference
#
######################################################################

body common control
{
version => "1.2.3";
bundlesequence => { "testbundle" };
version => "1.2.3";
bundlesequence => { "testbundle" };
}
########################################################

bundle agent testbundle
{
files:
# The back reference in a path only applies to the last link
# of the pathname, so the (tmp) gets ignored

"/tmp/(cf3)_(.*)"
edit_line => myedit("second $(match.2)");

# but ...

# "/tmp/cf3_test"
# create => "true",
# edit_line => myedit("second $(match.1)");

# The back reference in a path only applies to the last link
# of the pathname, so the (tmp) gets ignored
"/tmp/(cf3)_(.*)" edit_line => myedit("second $(match.2)");
# but ...
# "/tmp/cf3_test"
# create => "true",
# edit_line => myedit("second $(match.1)");
}
########################################################

bundle edit_line myedit(parameter)
{
vars:
"edit_variable" string => "private edit variable is $(parameter)";
"edit_variable" string => "private edit variable is $(parameter)";

insert_lines:
"$(edit_variable)";

"$(edit_variable)";
}
6 changes: 3 additions & 3 deletions content/examples/example-snippets/basic_example.cf
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
body common control
{
bundlesequence => { "main" };
inputs => { "$(sys.libdir)/stdlib.cf" };
bundlesequence => { "main" };
inputs => { "$(sys.libdir)/stdlib.cf" };
}

bundle agent main
{
# example
# example
}
9 changes: 5 additions & 4 deletions content/examples/example-snippets/bsd_flags.cf
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
body common control
{
bundlesequence => { "test" };
bundlesequence => { "test" };
}

bundle agent test
{
files:
freebsd::
"/tmp/newfile"
create => "true",
perms => setbsd;
create => "true",
perms => setbsd;
}

body perms setbsd
{
bsdflags => { "+uappnd","+uchg", "+uunlnk", "-nodump" };
bsdflags => { "+uappnd", "+uchg", "+uunlnk", "-nodump" };
}
11 changes: 5 additions & 6 deletions content/examples/example-snippets/change_detection.cf
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
body common control
{
bundlesequence => { "testbundle" };
inputs => { "cfengine_stdlib.cf" };
bundlesequence => { "testbundle" };
inputs => { "cfengine_stdlib.cf" };
}
########################################################

bundle agent testbundle
{
files:
"/usr"
changes => detect_all_change,
"/usr"
changes => detect_all_change,
depth_search => recurse("inf"),
action => background;
action => background;
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
body common control
{
bundlesequence => { "example" };
bundlesequence => { "example" };
}
###########################################################

body contain cd(dir)
{
chdir => "${dir}";
useshell => "true";
chdir => "${dir}";
useshell => "true";
}

bundle agent example
{
commands:
"/bin/pwd"
contain => cd("/tmp");
"/bin/pwd" contain => cd("/tmp");
}
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
bundle agent check_perms
{
vars:
"ns_files" slist => {
"/local/iu/logs/admin",
"/local/iu/logs/security",
"/local/iu/logs/updates",
"/local/iu/logs/xfer"
"ns_files"
slist => {
"/local/iu/logs/admin",
"/local/iu/logs/security",
"/local/iu/logs/updates",
"/local/iu/logs/xfer",
};

files:
NameServers::
"/local/dns/pz"
perms => mo("644","dns"),
depth_search => recurse("1"),
file_select => exclude("secret_file");
perms => mo("644", "dns"),
depth_search => recurse("1"),
file_select => exclude("secret_file");

"/local/iu/dns/pz/FixSerial"
perms => m("755"),
file_select => plain;
perms => m("755"),
file_select => plain;

"$(ns_files)"
perms => mo("644","dns"),
file_select => plain;
perms => mo("644", "dns"),
file_select => plain;

"$(ftp)/pub"
perms => mog("644","root","other");
"$(ftp)/pub" perms => mog("644", "root", "other");

"$(ftp)/pub"
perms => m("644"),
depth_search => recurse("inf");
perms => m("644"),
depth_search => recurse("inf");

"$(ftp)/etc" perms => mog("111","root","other");
"$(ftp)/usr/bin/ls" perms => mog("111","root","other");
"$(ftp)/dev" perms => mog("555","root","other");
"$(ftp)/usr" perms => mog("555","root","other");
"$(ftp)/etc" perms => mog("111", "root", "other");
"$(ftp)/usr/bin/ls" perms => mog("111", "root", "other");
"$(ftp)/dev" perms => mog("555", "root", "other");
"$(ftp)/usr" perms => mog("555", "root", "other");
}
7 changes: 3 additions & 4 deletions content/examples/example-snippets/check_filesystem_space.cf
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
body common control
{
bundlesequence => { "example" };
bundlesequence => { "example" };
}
###########################################################

bundle agent example
{
vars:
"free" int => diskfree("/tmp");
"free" int => diskfree("/tmp");

reports:
"Freedisk $(free)";
"Freedisk $(free)";
}
5 changes: 2 additions & 3 deletions content/examples/example-snippets/class_match_example.cf
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
body common control
{
bundlesequence => { "example" };
bundlesequence => { "example" };
}
###########################################################

bundle agent example
{
classes:
"do_it" and => { classmatch(".*_3"), "linux" };
"do_it" and => { classmatch(".*_3"), "linux" };

reports:
do_it::
Expand Down
78 changes: 35 additions & 43 deletions content/examples/example-snippets/client-server_example.cf
Original file line number Diff line number Diff line change
Expand Up @@ -3,94 +3,86 @@
# Simple test copy from server connection to cfServer
#
########################################################

#
# run this as follows:
#
# cf-serverd -f runtest_1.cf [-v]
# cf-agent -f runtest_2.cf
#
# Notice that the same file configures all parts of cfengine

########################################################

body common control
{
bundlesequence => { "testbundle" };
version => "1.2.3";
#fips_mode => "true";
bundlesequence => { "testbundle" };
version => "1.2.3";
#fips_mode => "true";
}
########################################################

bundle agent testbundle
{
files:
"/home/mark/tmp/testcopy"
comment => "test copy promise",
copy_from => mycopy("/home/mark/LapTop/words","127.0.0.1"),
perms => system,
"/home/mark/tmp/testcopy"
comment => "test copy promise",
copy_from => mycopy("/home/mark/LapTop/words", "127.0.0.1"),
perms => system,
depth_search => recurse("inf"),
classes => satisfied("copy_ok");
classes => satisfied("copy_ok");

"/home/mark/tmp/testcopy/single_file"
comment => "test copy promise",
copy_from => mycopy("/home/mark/LapTop/Cfengine3/trunk/README","127.0.0.1"),
perms => system;
"/home/mark/tmp/testcopy/single_file"
comment => "test copy promise",
copy_from => mycopy(
"/home/mark/LapTop/Cfengine3/trunk/README", "127.0.0.1"
),
perms => system;

reports:
copy_ok::
"Files were copied..";
}
#########################################################

body perms system
{
mode => "0644";
mode => "0644";
}
#########################################################

body depth_search recurse(d)
{
depth => "$(d)";
depth => "$(d)";
}
#########################################################

body copy_from mycopy(from,server)
body copy_from mycopy(from, server)
{
source => "$(from)";
servers => { "$(server)" };
compare => "digest";
encrypt => "true";
verify => "true";
copy_backup => "true"; #/false/timestamp
purge => "false";
type_check => "true";
force_ipv4 => "true";
trustkey => "true";
source => "$(from)";
servers => { "$(server)" };
compare => "digest";
encrypt => "true";
verify => "true";
copy_backup => "true";
#/false/timestamp
purge => "false";
type_check => "true";
force_ipv4 => "true";
trustkey => "true";
}
#########################################################

body classes satisfied(x)
{
promise_repaired => { "$(x)" };
persist_time => "0";
promise_repaired => { "$(x)" };
persist_time => "0";
}
#########################################################
# Server config
#########################################################

body server control
{
allowconnects => { "127.0.0.1" , "::1" };
allowallconnects => { "127.0.0.1" , "::1" };
trustkeysfrom => { "127.0.0.1" , "::1" };
# allowusers
allowconnects => { "127.0.0.1", "::1" };
allowallconnects => { "127.0.0.1", "::1" };
trustkeysfrom => { "127.0.0.1", "::1" };
# allowusers
}
#########################################################

bundle server my_access_rules()
{
access:
"/home/mark/LapTop"
admit => { "127.0.0.1" };
"/home/mark/LapTop" admit => { "127.0.0.1" };
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
body common control
{
bundlesequence => { "my_commands" };
inputs => { "$(sys.libdir)/stdlib.cf" };
bundlesequence => { "my_commands" };
inputs => { "$(sys.libdir)/stdlib.cf" };
}

bundle agent my_commands
Expand All @@ -11,6 +11,5 @@ bundle agent my_commands
"/usr/bin/update_db";

any::
"/etc/mysql/start"
contain => setuid("mysql");
"/etc/mysql/start" contain => setuid("mysql");
}
7 changes: 3 additions & 4 deletions content/examples/example-snippets/commands_example.cf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
body common control
{
bundlesequence => { "my_commands" };
inputs => { "$(sys.libdir)/stdlib.cf" };
bundlesequence => { "my_commands" };
inputs => { "$(sys.libdir)/stdlib.cf" };
}

bundle agent my_commands
Expand All @@ -11,6 +11,5 @@ bundle agent my_commands
"/usr/bin/update_db";

any::
"/etc/mysql/start"
contain => setuid("mysql");
"/etc/mysql/start" contain => setuid("mysql");
}
Loading
Loading