Forum: CFEngine Help
Subject: Re: Odd behavior overriding parameterized bundle values.
Author: n...@cmdln.org
Link to topic: https://cfengine.com/forum/read.php?3,25448,25499#msg-25499

Anyone else? I either don't understand how this works, or there is a bug.


The mear presence of a classes section changes the report output. Even if no 
classes are defined in the section and none of the variables or reports have 
any class restrictions (well reports has the cfengine class, but that's just to 
make reports always report"


body common control {

    bundlesequence => {
                        "main",
                        };

}

bundle agent main {


    vars:
        # Set some values to override defaults
        "array" string => "x";
        "array" string => "xx";

    methods:
        "any" usebundle => motd("main.array");

}

bundle agent motd(params){
    vars:
        "param_keys" slist => getindices("$(params)");

        # Set default values
        "conf"
            string => "value1",
            policy => "overridable";

        "conf"
            string => "value2",
            policy => "overridable";

        "conf"
            string => "value3",
            policy => "overridable";

        # Override default conf values with passed in paramaters
        "conf[$(param_keys)]"
            string => "$($(params)[$(param_keys)])",
            policy => "overridable";

        "conf_keys" slist => getindices("conf");

    #classes:
    #    "myclass" expression => isvariable("conf_keys");

    reports:
    cfengine::
        "conf[$(conf_keys)]: $(conf[$(conf_keys)])";
}



That produces reports as I expect.

R: conf: value3
R: conf: xx
R: conf: x


And this

body common control {

    bundlesequence => {
                        "main",
                        };

}

bundle agent main {


    vars:
        # Set some values to override defaults
        "array" string => "x";
        "array" string => "xx";

    methods:
        "any" usebundle => motd("main.array");

}

bundle agent motd(params){
    vars:
        "param_keys" slist => getindices("$(params)");

        # Set default values
        "conf"
            string => "value1",
            policy => "overridable";

        "conf"
            string => "value2",
            policy => "overridable";

        "conf"
            string => "value3",
            policy => "overridable";

        # Override default conf values with passed in paramaters
        "conf[$(param_keys)]"
            string => "$($(params)[$(param_keys)])",
            policy => "overridable";

        "conf_keys" slist => getindices("conf");

    classes:
    #    "myclass" expression => isvariable("conf_keys");

    reports:
    cfengine::
        "conf[$(conf_keys)]: $(conf[$(conf_keys)])";
}


produces the following, which shows the default values are not being overridden.

R: conf: value3
R: conf: value2
R: conf: value1


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

Reply via email to