Re: cf-agent and memory usage

Stefan Skoglund <[email protected]>
Newsgroups gmane.comp.sysutils.cfengine.general
Message-ID <[email protected]>
tis 2022-01-04 klockan 21:30 +0000 skrev Bas van der Vlies:
> 
> 
> > 
> > Hmm, anyone which has used classesmatching(".*", "hardclass") to
> > get
> > something which can be checked for in mustache templates using '#'
> > ie
> > equal to:
> > ---
> > {{#classes.debian_11}}
> > .....
> > {{/classes.debian_11}}
> > ---
> > 
> > I would need the classes from the environment or those defined in
> > def.json.
> > 
> I do not know what ypu exactly mean with this, but I use this in the
> SCL library a lot if I understand you correctly:. Classes defined in
> def.json are globally known and can be used in the mustache template.
> I do not use the datastate() functiion at all.
> eg:
> ```
> 
> {{#classes.SSH_PUBKEY_AUTHENTICATION}}
> AuthorizedKeysCommand {{vars.scl.ssh.authorized_keys_command}}
>     {{#classes.SLES}}
> AuthorizedKeysCommandUser
> {{vars.scl.ssh.authorized_keys_commanduser}}                         
>                                                                      
>                                       
>     {{/classes.SLES}}
>     {{#classes.debian}}
> AuthorizedKeysCommandUser
> {{vars.scl.ssh.authorized_keys_commanduser}}
>     {{/classes.debian}}
>     {{#classes.centos}}
> AuthorizedKeysCommandRunAs
> {{vars.scl.ssh.authorized_keys_commanduser}}
>     {{/classes.centos}}
> {{/classes.SSH_PUBKEY_AUTHENTICATION}}
> ```
> 
> the `SSH_PUBKEY_AUTHENTICATION` is defined in a `def.json` and
> converted by the SCL library to the  `SSH_PUBKEY_AUTHENTICATION`
> ```
>         classes: {
>             BATCHSERVER_NODE:  [  “debian_10” ]
>         },
>         ssh: {
>             classes: {
>                 PUBKEY_AUTHENTICATION: any
>             },
> ```

no i would want to create a custom template_data container
which below one key has the classes defined in def.json (and by cf-
agent from the environment) 
and via other keys a number of variables (variables defined by the
current agent.)

This is basically compared with the normal built in template data
getting rid of having to nominate containing namespace for a class in
the mustache template.

I would like to have something like this:
---
vars:
 "klassamling"
    slist => classes_matching( ".*", "source=augment", "WiFi");

 "templatedata"
   data => mergedata( '{  "klasser": klassamling,
                          "testvar": "22"
                        }');
files:
   "test"
     edit_template= "test.mustache",
     template_data => templatedata,
     template_method => "mustache";
-- 

test.mustache:
---
{{#klasser.is_kdc_hub}}
variabel = {{testvar}}
{{/klasser.is_kdc_hub}}
---

For this to work if i understand mustache correctly would really mean
having some method of going from a string to a key in "klasser" where
the key's value is true ?

ONE another method would be to call datastate early on in my policy,
pull out the classes tree only and when if some agent wants access,
they can do so using the container's path - ie:

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}}
----

-- 
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/391f128c7f95d27a65572c9ee3587ddabf20e2e7.camel%40agj.net.
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.