Movatterモバイル変換


[0]ホーム

URL:


CFEngine documentation homepage

Language concepts

Suggest changes
Table of contents

There is only one grammatical form for statements in the language:

code
bundlebundle_typename{promise_type:classes::"promiser"->{"promisee1","promisee2",...}attribute_1=>value_1,attribute_2=>value_2,...attribute_n=>value_n;}

In addition, CFEngine bodies can be defined and used as attribute values. Here's a real-life example of a body and its usage.

code
bodyedit_defaultsno_backup{edit_backup=>"false";}...andelsewhere,notingtheattributenamematchesthebodytype...files:"myfile"edit_defaults=>no_backup;

You can recognizeeverything in CFEngine from just those few concepts.

A declaration about thestate we desire to maintain (e.g., the permissionsor contents of a file, the availability or absence of a service, the(de)installation of a package).

A collection of promises.

A part of a promise which details and constrains its nature, possibly inseparate and re-usable parts. Effectively a body is like a promise attribute that has several parameters.

CFEngine's boolean classifiers that describe context.

An association of the form "LVALUErepresents RVALUE", where RVALUE may be ascalar value or a list of scalar values: a string, integer or real number.

This documentation about the language concepts introduces in addition

Syntax, identifiers and names

The CFEngine 3 language has a few simple rules:

  • CFEngine built-in words, names of variables, bundles, body templates and classes may only contain the usual alphanumeric and underscore characters (a-zA-Z0-9_)
  • All other 'literal' data must be quoted.
  • Declarations of promise bundles in the form:

    code
    bundle agent-type identifier{...}

    whereagent-type is the CFEngine component responsible for maintaining the promise.

  • Declarations of promise body-parts in the form:

    code
    body constraint_type template_identifier{...}

    matching and expanding on a reference inside a promise of the formconstraint_type => template_identifier

  • attribute expressions in the body of a promise take the form

    code
    left-hand-side (CFEngine_word) => right-hand-side (user defined data).

    This can take several forms:

    code
    cfengine_word => user_defined_template(parameters)              user_defined_template              builtin_function()              "quoted literal scalar"              { list }

    In each of these cases, the right hand side is a user choice.

    CFEngine uses manyconstraint expressions as part of the body of a promise. These take the form: left-hand-side (CFEngine word) '=>' right-hand-side (user defined data). This can take several forms:

    code
    cfengine_word => user_defined_template(parameters)    user_defined_template    builtin_function()    "quoted literal scalar"    { list }

    In each of these cases, the right hand side is a user choice.

Filenames and paths

Filenames in Unix-like operating systems use the forward slash '/'character for their directory separator. All references to filelocations must be absolute pathnames in CFEngine, i.e. they mustbegin with a complete specification of which directory they are in or with a variable reference that resolves to that.For example:

code
/etc/passwd/var/cfengine/masterfiles/distfile$(sys.masterdir)/distfile # usually the same thing in 3.6

The only place where it makes sense to refer to a file without acomplete directory specification is when searching throughdirectories for different kinds of file, e.g. in pattern matching

code
leaf_name => { "tmp_.*", "output_file", "core" };

Here, one can write core without a path, because one is looking forany file of that name in a number of directories.

The Windows operating systems traditionally use a differentfilename convention. The following are all valid absolute filenames under Windows:

code
c:\winnt"c:\spaced name"c:/winnt/var/cfengine/inputs//fileserver/share2/dir

The 'drive' name "C:" in Windows refers to a partition or device.Unlike Unix, Windows does not integrate these seamlessly into asingle file-tree. This is not a valid absolute filename:

code
\var\cfengine\inputs

Paths beginning with a backslash are assumed to be win32 paths.They must begin with a drive letter or double-slash server name.

Note that in many cases, you havesys.inputdir and otherSpecial variables that work equally well on Windows and non-Windowssystem.

Note in recent versions of Cygwin you can decide to use the/cygdrive to specify a path to windows file E.g/cygdrive/c/myfile means c:\myfile or you can do it straight awayin CFEngine asc:\myfile.

Still need help?

Chat Ask a question on Github Mailing list
Version 
master3.24 (LTS)3.21 (LTS)view all versions

[8]ページ先頭

©2009-2025 Movatter.jp