Re: cf-agent and memory usage

Bas van der Vlies <[email protected]>
Newsgroups gmane.comp.sysutils.cfengine.general
Message-ID <[email protected]>
> 
> services/main.cf:
> ---
> "datastate" 
>   data => datastate();
> "klasser"
>   data => mergedata( datastate[classes]);
> ---
> 
> And from other agent refer to klasser :
> ---
>  "template_data"
>    data => mergedata( '{ "klasser": default:main.klasser,
>                          "var2":    3,
>                          "var3":    4
> }');
> --- 
> 
> That agent is in another namespace, for example "WiFi".
> 
> My idea is to being able to tell a developer which wants to control
> some type of text config file : refer to classes and vars  using a
> short name (and not having to tell/educate them about the concept of
> namespaces in cfengine.)  
> 
> A lot of complexity .... to be able to say :
> ----
> test = {{test}}
> 
> {{#iftest}}
> test2 = {{test2}}
> {{/iftest}}
> ---
> 
> Instead of :
> ---
> test = {{vars.DNS:agentName.test}}
> {{#classes.DNS:iftest}}
> test2 = {{vars.DNS:agentName.test2}}
> {{/classes.DNS:iftest}}


Your setup is different then ours. I get your point of make it easy for developers. the scl library function to genenerate the file from a template can handle an optional data section arg to support the short names in templates. Do not know if is supports the namespaces. Maybe it can help you to solve your issue:
```
bundle agent scl_mustache_cf_data_2_file(bundle_name, template_file, destination, data_section)
{

    vars:
        any::
            "template_dir"     string => "$(def.node_template_dir)/$(bundle_name)";

            "data_section_str" string => format("%S", "$(data_section)"),
                if => "DEBUG_$(bundle_name)|DEBUG|DEBUG_MUSTACHE";

    classes:
        #"data_section"     expression => isvariable("data_section"),
        "data_section"     expression => regcmp("[a-zA-Z].*", "$(data_section)"),
            comment => "data_section defined do use it",
            scope => "bundle";

        "destination_set" expression => regcmp("^/.*", "$(destination)");


    files:
       data_section.destination_set::
                "$(destination)"
                    comment         => "Mustache expand with defined data_section variable ",
                    create          => "true",
                    edit_template   => "$(template_dir)/$(template_file)",
                    template_method => "mustache",
                    #template_data   => mergedata("scl.$(bundle_name)[$(data_section)]"),
                    template_data   => mergedata("$(data_section)"),
                    classes         => if_repaired("scl$(destination)");

       !data_section.destination_set::
                "$(destination)"
                    comment         => "Mustache expand with cfengine json data",
                    create          => "true",
                    edit_template   => "$(template_dir)/$(template_file)",
                    template_method => "mustache",
                    classes         => if_repaired("scl$(destination)”);
}
```



--
Bas van der Vlies
| High Performance Computing & Visualization | SURF| Science Park 140 | 1098 XG  Amsterdam
| T +31 (0) 20 800 1300  | [email protected] | www.surf.nl |





-- 
You received this message because you are subscribed to the Google Groups "help-cfengine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/help-cfengine/6083C2EB-651C-48C8-8CFC-8F9611699253%40surf.nl.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.