I figured out how to send an array of pattern/replacement pairs to a generic 
edit_line body based on the set_variable_values bundle in the stdlib (see 
below.) What I don't fully understand is how the array passing works, 
specifically, why I need to fully qualify the array, and not use a "@" ... I 
can't find anything in the docs about this, my best guess is that what's being 
sent is a reference to the array and not the array itself. I'd like to 
understand what's happening here if somebody can clarify;

edit_line   =>  test_edit("test_bundle.edits");




bundle agent test_bundle
{
vars:

        "edits[#OPTIONS=\"\"]"              string  =>  "OPTIONS=\"-O fsc\"";
        "edits[#APPEND_OPTIONS=\"yes\"]"   string  =>  "APPEND_OPTIONS=\"yes\"";

files:

    vcf::

        "/tmp/autofs"
            handle      =>  "test_edit",
            edit_line   =>  test_edit("test_bundle.edits");
}

bundle edit_line test_edit(e)
{
vars:
    
    "index"                 slist   =>  getindices("$(e)");

replace_patterns:

    "$(index)"      replace_with    =>  value("$($(e)[$(index)])");
}


On Feb 18, 2011, at 4:03 PM, [email protected] wrote:

> Forum: Cfengine Help
> Subject: Re: Cfengine Help: Re: edit_line / syntax help
> Author: phnakarin
> Link to topic: https://cfengine.com/forum/read.php?3,20761,20763#msg-20763
> 
> You may either do
> 
> (1) editing the file 4 times or
> 
> 
> "/tmp/testfile"
> edit_line => test_edit("string1","string1Edit");
> 
> "/tmp/testfile"
> edit_line => test_edit("string2","string2Edit");
> 
> "/tmp/testfile"
> edit_line => test_edit("string3","string3Edit");
> 
> "/tmp/testfile"
> edit_line => test_edit("string4","string4Edit");
> 
> 
> 
> (2) creating your own special edit_line body to edit all of them at once.
> 
> 
> "/tmp/testfile"
> edit_line => my_own_edit;
> 
> bundle edit_line my_own_edit
> {
> replace_patterns:
>    "string1" replace_with => value("string1Edit)");
>    "string2" replace_with => value("string2Edit)");
>    "string3" replace_with => value("string3Edit)");
>    "string4" replace_with => value("string4Edit)");
> }
> 
> 
> Cheers,
> --Nakarin
> 
> _______________________________________________
> Help-cfengine mailing list
> [email protected]
> https://cfengine.org/mailman/listinfo/help-cfengine

_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to