I have the following promises.

bundle common g
{
        vars:
                "alias_vi"              string  => "alias vi=\"vim\"";
                "bashrc_loc"    string  => "/etc/bashrc";
}
Bundle agent exampleInsertLine
{
        vars:
                "alias_editor"
                        int                     => 
countlinesmatching("$(g.alias_vi)","$(g.bashrc_loc)"),
                        comment         => "check if vi alias exists";
        classes:
                "alias_exists"
                        expression              => 
isgreaterthan("$(alias_editor)", 0),
                        comment         => "determine if vi alias exists";
        files:
                !alias_exists::
                        "$(g.bashrc_loc)"
                                edit_line       => add_vi_alias,
                                comment => "if alias does not exist, insert 
it.";
        reports:
                alias_exists::
                        "--> alias for vi pointing to vim exists.";
}
bundle edit_line add_vi_alias
{
        insert_lines:
                "$(g.alias_vi)"
                        comment         => "inserting the alias for vi",
                        classes         => if_repaired("alias_inserted");
        reports:
                alias_inserted::
                        "alias for vi has been inserted.",
                                comment => "inform admin that an alias for vi 
has been added";
}

Whenever I run the promises above, I get the following error.

!! Duplicate selection of value for variable "alias_editor" in scope 
exampleInsertLine
!! Rule from /var/cfengine/inputs/test_insert_lines.cf at/before line 40

Line 40 points to the "}" of the add_vi_alias bundle.  The report in this 
bundle is not working.

The alias gets inserted into /etc/bashrc if it is not there.  However, the 
error concerns me.  Help.

On the other hand, the reports promise in add_vi_alias bundle will not work.  
Help.

Regards,
j
_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to