1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
#+begin_src cfengine3
bundle agent __main__
{
files:
"/tmp/example-edit.empty_before_use.one" create => "true";
"/tmp/example-edit.empty_before_use.two" create => "true";
"/tmp/example-edit.empty_before_use.one"
edit_line => show_edit_empty_before_use,
edit_defaults => my_empty_file_before_editing;
"/tmp/example-edit.empty_before_use.two"
edit_line => show_edit_empty_before_use;
}
bundle edit_line show_edit_empty_before_use
{
reports:
"$(with)"
with => concat( "The promise to edit '$(edit.filename)' was ",
"instructed to ignore any pre-existing content." ),
if => strcmp( "true", "$(edit.empty_before_use)");
"$(with)"
with => concat( "The promise to edit '$(edit.filename)' was ",
"not instructed to ignore any pre-existing content."),
if => strcmp( "false", "$(edit.empty_before_use)");
"$(with)"
with => concat ( "This version of CFEngine does not know if the",
"edit operation is expected to ignore pre-existing ",
"content the variable 'edit.empty_before_use' does ",
"not exist"),
unless => isvariable ( "edit.empty_before_use" );
}
body edit_defaults my_empty_file_before_editing
{
empty_file_before_editing => "true"; # The variable
# edit.empty_before_use allows this
# to be known from within an
# edit_line bundle.
}
#+end_src
###############################################################################
#+begin_src example_output
#@ ```
#@ R: The promise to edit '/tmp/example-edit.empty_before_use.one' was instructed to ignore any pre-existing content.
#@ R: The promise to edit '/tmp/example-edit.empty_before_use.two' was not instructed to ignore any pre-existing content.
#@ ```
#+end_src
|