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,25521#msg-25521

Here is the shortened version, not sure how to shorten it much more.

I have 2 default values set in the internal conf array
value1 is "default value1" and value2 is "default value2"

I can override a value as long as the classes section is not present.

R: conf: overridden value1
R: conf: default value2


But not if I uncomment the classes section.

R: conf: default value1
R: conf: default value2



Here is the standalone test.


body common control {

    bundlesequence => {
                        "main",
                        };

}

bundle agent main {


    vars:
        # Set some values to override defaults
        "array" string => "overridden value1";

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

}

bundle agent test(params){
    vars:
        "bundlename" string => "test";

        "param_keys" slist => getindices("$(params)");

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

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

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

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

    # Try uncommenting this classes section
    #     the section can be empty (no need to comment out "myclass"
    #     either way the presence of the classes section changes
    #     the reports output)
    #classes:
    #    "myclass" expression => isvariable("conf_keys");

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


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

Reply via email to