File: edit.empty_before_use.cf

package info (click to toggle)
cfengine3 3.24.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 37,552 kB
  • sloc: ansic: 163,161; sh: 10,296; python: 2,950; makefile: 1,744; lex: 784; yacc: 633; perl: 211; pascal: 157; xml: 21; sed: 13
file content (54 lines) | stat: -rw-r--r-- 2,008 bytes parent folder | download | duplicates (3)
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