Community Open Promise Body Library


Next: , Previous: (dir), Up: (dir)

CFEngine-Open-Promise-Body-Library

COMPLETE TABLE OF CONTENTS

Summary of contents


Previous: Top, Up: Top

1 The Purpose Of This Handbook


CFEngine is built on promises. Promises were chosen as the model for CFEngine's configuration language, because they represent an expression of intention.

If you are using custom scripts to manage your systems, you are using recipes. Take a look at any cookbook and you will see that all recipes look the same: take flour, eggs, butter, sugar ... and you know nothing because you can make a hundred things from these steps. If you don't make clear your intention, it is very hard to know what the recipe is supposed to be: is it a cake, a waffle, a pastry?

The same is true in system administration. Recipes are not merely scripts, they encapsulate knowledge and experience. Their value is in communicating desired outcomes or states.

This library of standard components is like a cookbook that tells you only how to make basics well. It gives these basic skills names and therefore gives you a common vocabulary – you will put together these basics in creative ways to build your systems.



Please contribute to this guide by helping to develop a repertoire of basic skills and names. This collection should be comprehensive but parsimonious. Basics are only basics if they are few and carefully thought out. This is a work in progress and your experience is welcome.

This library will be moderated by CFEngine, and contributions and discussions ca n be made to the help-cfengine@cfengine.org mailing list.


Next: , Previous: The Purpose Of This Handbook, Up: The Purpose Of This Handbook

1.1 body action bg(elapsed,expire)

body action bg(elapsed,expire)
{
=>
=>
=>
}



Next: , Previous: body action bg, Up: The Purpose Of This Handbook

1.2 body action if_elapsed(x)

body action if_elapsed(x)
{
=>
=>
}



Next: , Previous: body action if_elapsed, Up: The Purpose Of This Handbook

1.3 body action ifwin_bg

body action ifwin_bg
{
windows::
=>
}




Next: , Previous: body action ifwin_bg, Up: The Purpose Of This Handbook

1.4 body action immediate

body action immediate
{
=>
}



Next: , Previous: body action immediate, Up: The Purpose Of This Handbook

1.5 body action measure_performance(x)

body action measure_performance(x)
{
=>
=>
=>
}



Next: , Previous: body action measure_performance, Up: The Purpose Of This Handbook

1.6 body action sample_rate(x)

body action sample_rate(x)
{
=>
=>
}


Next: , Previous: body action sample_rate, Up: The Purpose Of This Handbook

1.7 body action warn_only

body action warn_only
{
=>
=>
}



Next: , Previous: body action warn_only, Up: The Purpose Of This Handbook

1.8 body changes detect_all_change

body changes detect_all_change

# This is fierce, and will cost disk cycles



{
=>
=>
=>
}



Next: , Previous: body changes detect_all_change, Up: The Purpose Of This Handbook

1.9 body changes detect_content

body changes detect_content

# This is a cheaper alternative



{
=>
=>
=>
}



Next: , Previous: body changes detect_content, Up: The Purpose Of This Handbook

1.10 body classes cf2_if_else(yes,no)

body classes cf2_if_else(yes,no)

# meant to match cf2 semantics



{
=>
=>
=>
=>
}



Next: , Previous: body classes cf2_if_else, Up: The Purpose Of This Handbook

1.11 body classes if_else(yes,no)

body classes if_else(yes,no)

{
=>
=>
=>
=>
=>
}



Next: , Previous: body classes if_else, Up: The Purpose Of This Handbook

1.12 body classes if_notkept(x)

body classes if_notkept(x)
{
=>
=>
=>
}



Next: , Previous: body classes if_notkept, Up: The Purpose Of This Handbook

1.13 body classes if_ok(x)

body classes if_ok(x)
{
=>
=>
}



Next: , Previous: body classes if_ok, Up: The Purpose Of This Handbook

1.14 body classes if_repaired(x)

body classes if_repaired(x)
{
=>
}



Next: , Previous: body classes if_repaired, Up: The Purpose Of This Handbook

1.15 body classes state_repaired(x)

body classes state_repaired(x)
{
=>
=>
}

# agent










Next: , Previous: body classes state_repaired, Up: The Purpose Of This Handbook

1.16 body contain in_dir(s)

body contain in_dir(s)
{
=>
}



Next: , Previous: body contain in_dir, Up: The Purpose Of This Handbook

1.17 body contain in_shell

body contain in_shell
{
=>
}



Next: , Previous: body contain in_shell, Up: The Purpose Of This Handbook

1.18 body contain jail(owner,root,dir)

body contain jail(owner,root,dir)
{
=>
=>
=>
=>
}





Next: , Previous: body contain jail, Up: The Purpose Of This Handbook

1.19 body contain setuid(x)

body contain setuid(x)
{
=>
=>
}



Next: , Previous: body contain setuid, Up: The Purpose Of This Handbook

1.20 body contain setuid_sh(x)

body contain setuid_sh(x)
{
=>
=>
}



Next: , Previous: body contain setuid_sh, Up: The Purpose Of This Handbook

1.21 body contain setuidgid_sh(owner,group)

body contain setuidgid_sh(owner,group)
{
=>
=>
=>
}



Next: , Previous: body contain setuidgid_sh, Up: The Purpose Of This Handbook

1.22 body contain silent

body contain silent
{
=>
}



Next: , Previous: body contain silent, Up: The Purpose Of This Handbook

1.23 body contain silent_in_dir(s)

body contain silent_in_dir(s)
{
=>
=>
}



Next: , Previous: body contain silent_in_dir, Up: The Purpose Of This Handbook

1.24 body copy_from local_cp(from)

body copy_from local_cp(from)
{
=>
}


# Copy only if the file does not already exist, i.e. seed the placement




Next: , Previous: body copy_from local_cp, Up: The Purpose Of This Handbook

1.25 body copy_from no_backup_cp(from)

body copy_from no_backup_cp(from)
{
=>
=>
}



Next: , Previous: body copy_from no_backup_cp, Up: The Purpose Of This Handbook

1.26 body copy_from no_backup_rcp(from,server)

body copy_from no_backup_rcp(from,server)
{
=>
=>
=>
=>
}



Next: , Previous: body copy_from no_backup_rcp, Up: The Purpose Of This Handbook

1.27 body copy_from remote_cp(from,server)

body copy_from remote_cp(from,server)
{
=>
=>
=>
}



Next: , Previous: body copy_from remote_cp, Up: The Purpose Of This Handbook

1.28 body copy_from secure_cp(from,server)

body copy_from secure_cp(from,server)
{
=>
=>
=>
=>
=>
}



Next: , Previous: body copy_from secure_cp, Up: The Purpose Of This Handbook

1.29 body copy_from seed_cp(from)

body copy_from seed_cp(from)
{
=>
=>
}



Next: , Previous: body copy_from seed_cp, Up: The Purpose Of This Handbook

1.30 body copy_from sync_cp(from,server)

body copy_from sync_cp(from,server)
{
=>
=>
=>
=>
}



Next: , Previous: body copy_from sync_cp, Up: The Purpose Of This Handbook

1.31 body delete tidy

body delete tidy

{
=>
=>
}



Next: , Previous: body delete tidy, Up: The Purpose Of This Handbook

1.32 body depth_search recurse(d)

body depth_search recurse(d)

{
=>
=>

=>
}



Next: , Previous: body depth_search recurse, Up: The Purpose Of This Handbook

1.33 body depth_search recurse_ignore(d,list)

body depth_search recurse_ignore(d,list)
{
=>
=>
}



Next: , Previous: body depth_search recurse_ignore, Up: The Purpose Of This Handbook

1.34 body edit_defaults empty

body edit_defaults empty
{
=>
=>
=>
}



Next: , Previous: body edit_defaults empty, Up: The Purpose Of This Handbook

1.35 body edit_defaults std_defs

body edit_defaults std_defs
{
=>
=>
=>
}



Next: , Previous: body edit_defaults std_defs, Up: The Purpose Of This Handbook

1.36 body edit_field col(split,col,newval,method)

body edit_field col(split,col,newval,method)
{
=>
=>
=>
=>
=>
=>
=>
}




Next: , Previous: body edit_field col, Up: The Purpose Of This Handbook

1.37 body edit_field quoted_var(newval,method)

body edit_field quoted_var(newval,method)
{
=>
=>
=>
=>
=>
=>
=>
}



Next: , Previous: body edit_field quoted_var, Up: The Purpose Of This Handbook

1.38 body file_select by_name(names)

body file_select by_name(names)
{
=>
=>
}



Next: , Previous: body file_select by_name, Up: The Purpose Of This Handbook

1.39 body file_select days_old(days)

body file_select days_old(days)
{
=>
=>
}



Next: , Previous: body file_select days_old, Up: The Purpose Of This Handbook

1.40 body file_select dirs

body file_select dirs
{
=>
=>
}



Next: , Previous: body file_select dirs, Up: The Purpose Of This Handbook

1.41 body file_select ex_list(names)

body file_select ex_list(names)
{
=>
=>
}



Next: , Previous: body file_select ex_list, Up: The Purpose Of This Handbook

1.42 body file_select exclude(name)

body file_select exclude(name)
{
=>
=>
}



Next: , Previous: body file_select exclude, Up: The Purpose Of This Handbook

1.43 body file_select name_age(name,days)

body file_select name_age(name,days)
{
=>
=>
=>
}



Next: , Previous: body file_select name_age, Up: The Purpose Of This Handbook

1.44 body file_select plain

body file_select plain
{
=>
=>
}


Next: , Previous: body file_select plain, Up: The Purpose Of This Handbook

1.45 body file_select size_range(from,to)

body file_select size_range(from,to)
{
=>
=>
}



Next: , Previous: body file_select size_range, Up: The Purpose Of This Handbook

1.46 body link_from linkchildren(tofile)

body link_from linkchildren(tofile)
{
=>
=>
=>
=>
=>
}



Next: , Previous: body link_from linkchildren, Up: The Purpose Of This Handbook

1.47 body link_from ln_s(x)

body link_from ln_s(x)
{
=>
=>
=>
}



Next: , Previous: body link_from ln_s, Up: The Purpose Of This Handbook

1.48 body location start

body location start
{
=>
}




Next: , Previous: body location start, Up: The Purpose Of This Handbook

1.49 body match_value scan_log(line)

body match_value scan_log(line)
{
=>
=>
}



Next: , Previous: body match_value scan_log, Up: The Purpose Of This Handbook

1.50 body mount nfs(server,source)

body mount nfs(server,source)
{
=>
=>
=>
=>
}




Next: , Previous: body mount nfs, Up: The Purpose Of This Handbook

1.51 body mount nfs_p(server,source,perm)

body mount nfs_p(server,source,perm)
{
=>
=>
=>
=>
=>
}



Next: , Previous: body mount nfs_p, Up: The Purpose Of This Handbook

1.52 body mount unmount

body mount unmount
{
=>
=>
=>
}



Next: , Previous: body mount unmount, Up: The Purpose Of This Handbook

1.53 body package_method apt

body package_method apt
{
=>
=>
=>
=>
=>
=>

have_aptitude::
=>
=>
=>

!have_aptitude::
=>
=>
=>
}



Next: , Previous: body package_method apt, Up: The Purpose Of This Handbook

1.54 body package_method freebsd

body package_method freebsd
{
any::

=>

 # Could use rpm for this

=>

 # Remember to escape special characters like |



=>
=>

=>
=>

=>

=>


=>
=>
}




Next: , Previous: body package_method freebsd, Up: The Purpose Of This Handbook

1.55 body package_method solaris (pkgname, spoolfile, adminfile)

body package_method solaris (pkgname, spoolfile, adminfile)
{
=>
=>
=>
=>
=>
=>
=>
=>
=>
=>
}




Next: , Previous: body package_method solaris, Up: The Purpose Of This Handbook

1.56 body package_method yum

body package_method yum
{
=>
=>

# Remember to escape special characters like |



=>
=>
=>

=>
=>

=>
=>
=>
}


# The solaris package system is poorly designed, with too many different

# names to track. See the example in tests/units/unit_package_solaris.cf

# to see how to use this




Next: , Previous: body package_method yum, Up: The Purpose Of This Handbook

1.57 body package_method zypper

body package_method zypper


{
=>

=>
=>
=>
=>
=>
=>

=>
=>
=>

=>
=>
=>
=>

=>
=>
}



Next: , Previous: body package_method zypper, Up: The Purpose Of This Handbook

1.58 body perms m(mode)

body perms m(mode)
{
=>
}



Next: , Previous: body perms m, Up: The Purpose Of This Handbook

1.59 body perms mo(mode,user)

body perms mo(mode,user)
{
=>
=>
}



Next: , Previous: body perms mo, Up: The Purpose Of This Handbook

1.60 body perms mog(mode,user,group)

body perms mog(mode,user,group)
{
=>
=>
=>
}



Next: , Previous: body perms mog, Up: The Purpose Of This Handbook

1.61 body perms og(u,g)

body perms og(u,g)
{
=>
=>
}



Next: , Previous: body perms og, Up: The Purpose Of This Handbook

1.62 body perms owner(user)

body perms owner(user)
{
=>
}



Next: , Previous: body perms owner, Up: The Purpose Of This Handbook

1.63 body process_count check_range(name,lower,upper)

body process_count check_range(name,lower,upper)
{
=>
=>
}




Next: , Previous: body process_count check_range, Up: The Purpose Of This Handbook

1.64 body rename disable

body rename disable
{
=>
}



Next: , Previous: body rename disable, Up: The Purpose Of This Handbook

1.65 body rename rotate(level)

body rename rotate(level)
{
=>
}



Next: , Previous: body rename rotate, Up: The Purpose Of This Handbook

1.66 body rename to(file)

body rename to(file)
{
=>
}



Next: , Previous: body rename to, Up: The Purpose Of This Handbook

1.67 body replace_with comment(c)

body replace_with comment(c)
{
=>
=>
}



Next: , Previous: body replace_with comment, Up: The Purpose Of This Handbook

1.68 body replace_with uncomment

body replace_with uncomment
{
=>
=>
}




Next: , Previous: body replace_with uncomment, Up: The Purpose Of This Handbook

1.69 body replace_with value(x)

body replace_with value(x)
{
=>
=>
}



Next: , Previous: body replace_with value, Up: The Purpose Of This Handbook

1.70 body select_process exclude_procs(x)

body select_process exclude_procs(x)
{
=>
=>
}



Next: , Previous: body select_process exclude_procs, Up: The Purpose Of This Handbook

1.71 body select_region INI_section(x)

body select_region INI_section(x)
{
=>
=>
}



Next: , Previous: body select_region INI_section, Up: The Purpose Of This Handbook

1.72 body volume min_free_space(free)

body volume min_free_space(free)
{
=>
=>
=>
=>
}



Next: , Previous: body volume min_free_space, Up: The Purpose Of This Handbook

1.73 bundle edit_line append_groups_starting(v)

bundle edit_line append_groups_starting(v)

 # For adding groups to /etc/group, needs

=>



{
vars:

=>

classes:

=>

insert_lines:

  "$($(v)[$(index)])",

=>

}



Next: , Previous: bundle edit_line append_groups_starting, Up: The Purpose Of This Handbook

1.74 bundle edit_line append_if_no_line(str)

bundle edit_line append_if_no_line(str)
{
insert_lines:

 "$(str)";
}



Next: , Previous: bundle edit_line append_if_no_line, Up: The Purpose Of This Handbook

1.75 bundle edit_line append_if_no_lines(list)

bundle edit_line append_if_no_lines(list)
{
insert_lines:

 "$(list)";
}



Next: , Previous: bundle edit_line append_if_no_lines, Up: The Purpose Of This Handbook

1.76 bundle edit_line append_user_field(group,field,allusers)

bundle edit_line append_user_field(group,field,allusers)

 # For adding users to to a file like /etc/group

 # at field position "field", comma separated subfields



{
vars:

=>

field_edits:

 "$(group).*"

=>
}



Next: , Previous: bundle edit_line append_user_field, Up: The Purpose Of This Handbook

1.77 bundle edit_line append_users_starting(v)

bundle edit_line append_users_starting(v)

 # For adding to /etc/passwd or etc/shadow, needs

=>



{
vars:

=>

classes:

=>

insert_lines:

  "$($(v)[$(index)])",

=>
}



Next: , Previous: bundle edit_line append_users_starting, Up: The Purpose Of This Handbook

1.78 bundle edit_line comment_lines_containing(regex,comment)

bundle edit_line comment_lines_containing(regex,comment)

 # Comment lines of a file containing a regex



{
replace_patterns:

=>
}



Next: , Previous: bundle edit_line comment_lines_containing, Up: The Purpose Of This Handbook

1.79 bundle edit_line comment_lines_matching(regex,comment)




class="red"> class="red"> Next:  accesskey="p" Up: The Purpose Of This Handbook
class="section">1.80
bundle edit_line delete_lines_matching(regex)
{
delete_lines:

  "$(regex)";
}



Next: , Previous: bundle edit_line delete_lines_matching, Up: The Purpose Of This Handbook

1.81 bundle edit_line expand_template(templatefile)

bundle edit_line expand_template(templatefile)

 # Read in the named text file and expand $(var)

 # inside the file



{
insert_lines:

   "$(templatefile)"

=>
=>
}



Next: , Previous: bundle edit_line expand_template, Up: The Purpose Of This Handbook

1.82 bundle edit_line resolvconf(search,list)

bundle edit_line resolvconf(search,list)

 # search is the search domains with space

 # list is an slist of nameserver addresses



{
delete_lines:

  "search.*";

insert_lines:

  "search $(search)";
  "nameserver $(list)";
}



Next: , Previous: bundle edit_line resolvconf, Up: The Purpose Of This Handbook

1.83 bundle edit_line set_user_field(user,field,val)

bundle edit_line set_user_field(user,field,val)

 # Set the value of field number "field" in

 # a :-field formatted file like /etc/passwd



{
field_edits:

 "$(user).*"

=>
}



Next: , Previous: bundle edit_line set_user_field, Up: The Purpose Of This Handbook

1.84 bundle edit_line set_variable_values(v)

bundle edit_line set_variable_values(v)

 # Sets the RHS of variables in the file of the form

 #   LHS = RHS

 # Adds a new line if no LHS exists, repairs RHS values if one does exist

 #

 # To use:

 #   1) Define an array, where the keys are the LHS and the values are the RHS

=>

=>

 #   2) The parameter passed to the edit_line promise is the fully qualified

 #



{
vars:

=>

  # Be careful if the index string contains funny chars



=>

field_edits:

  # match a line starting like the key = something



  "\s*$(index)\s*=.*"

=>
=>

insert_lines:

  "$(index)=$($(v)[$(index)])",

=>
}



Next: , Previous: bundle edit_line set_variable_values, Up: The Purpose Of This Handbook

1.85 bundle edit_line uncomment_lines_containing(regex,comment)

bundle edit_line uncomment_lines_containing(regex,comment)

 # Uncomment lines of a file where the regex matches

 # the text after the comment string



{
replace_patterns:

=>
}



Next: , Previous: bundle edit_line uncomment_lines_containing, Up: The Purpose Of This Handbook

1.86 bundle edit_line uncomment_lines_matching(regex,comment)

bundle edit_line uncomment_lines_matching(regex,comment)

 # Uncomment lines of a file where the regex matches

 # the text after the comment string



{
replace_patterns:

=>
}



Previous: bundle edit_line uncomment_lines_matching, Up: The Purpose Of This Handbook

1.87 bundle edit_line warn_lines_matching(regex)

bundle edit_line warn_lines_matching(regex)
{
delete_lines:

=>
}


Table of Contents