Table of Contents
General Examples
Table of Contents
Basic Example
To get started with CFEngine, you can imagine the following template for entering examples. This part of the code is common to all the examples.
body common control
{
bundlesequence => { "main" };
inputs => { "$(sys.libdir)/stdlib.cf" };
}
bundle agent main
{
# example
}
The general pattern
The general pattern of the syntax is like this (colors in html version: red, CFEngine word; blue, user-defined word):
bundle component name(parameters)
{
what_type:
where_when::
# Traditional comment
"promiser" -> { "promisee1", "promisee2" },
comment => "The intention ...",
handle => "unique_id_label",
attribute_1 => body_or_value1,
attribute_2 => body_or_value2;
}
Hello world
body common control
{
bundlesequence => { "hello" };
}
bundle agent hello
{
reports:
linux::
"Hello world!";
}
Array example
body common control
{
bundlesequence => { "array" };
}
bundle common g
{
vars:
"array[1]" string => "one";
"array[2]" string => "two";
}
bundle agent array
{
vars:
"localarray[1]" string => "one";
"localarray[2]" string => "two";
reports:
linux::
"Global $(g.array[1]) and $(localarray[2])";
}