Pablo,

the recursive search is only working for files promises, so it's
unlikely you can pass a path to your bundle and hope it will work out.
>From my point of view, the desired state can be achieved by obtaining
an slist for files using readstringlist() call over execresult() for
ls or find output. The choice between ls and find depends on whether
your certs directory is plain or structured, respectively.

2010/11/25  <no-re...@cfengine.com>:
> Forum: Cfengine Help
> Subject: Apply a bundle to the content of a given path
> Author: orviz
> Link to topic: https://cfengine.com/forum/read.php?3,19395,19395#msg-19395
>
> Hi all,
>
> I've got a bundle that checks if a given x509 certificate (passed as an 
> argument) is expired and if so it gets deleted:
>
>
> bundle agent expired_x509files(name) {
>    vars:
>        "pem_date"                   string          => 
> execresult("/usr/bin/openssl x509 -in $(name) -noout -enddate | /bin/cut 
> -d'=' -f2", "useshell");
>        "pem_date_epoch"        string          => execresult("/bin/date 
> -d'$(pem_date)' +%s", "useshell");
>        "current_date_epoch"    string          => execresult("/bin/date +%s", 
> "useshell");
>
>    classes:
>        "expired"                      expression  => 
> islessthan("$(pem_date_epoch)", "$(current_date_epoch)");
>
>    files:
>        expired::
>            "$(name)"
>                delete => tidy;
> }
>
>
> This works great if applied to a file:
>
>
> bundle agent mycert {
>    methods:
>        "any"
>            usebundle => expired_x509files("/path/to/certs/mycert.pem");
> }
>
>
> But I do not have a clue on how to do this for an entire path. An 
> unsuccessful attempt:
>
>
> bundle agent certs {
>    methods:
>        "any"
>            usebundle => expired_x509files("/path/to/certs/.*");
> }
>
>
> Note that I do not know a priori what the content of the path is. Could 
> anyone shed some light on this?
>
> Thanks in advance,
> Pablo.
>
> _______________________________________________
> Help-cfengine mailing list
> Help-cfengine@cfengine.org
> https://cfengine.org/mailman/listinfo/help-cfengine
>



-- 
SY, Seva Gluschenko.
_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to