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
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine