how can i set a class if a package is installed ?
Background : i want to trigger a file modification only if a package is installed (optional in a specific version).
My (example) code unfortunately doesn't work :
vars:
"cfengine_rpm" data => packagesmatching("cfengine-nova", ".*", ".*", ".*");
"cfengine_rpm_installed" slist => getindices(cfengine_rpm);
classes:
"cfengine_installed" expression => some("cfengine", cfengine_rpm_installed);
reports:
cfengine_installed::
"cfEngine is installed ";
# Bonus :-)
"cfEngine Version : $(cfengine_rpm[$(cfengine_rpm_installed)][version])";
Addendum : this question is similar to CFEngine - set variable if a specific package version is installed but I would like to ask for coded hints or solutions :-)
I tweaked your policy a bit and provided comments in line. I think your main issue was that you were expecting the index of the returned packagesmatching() data to be indexed by package name, instead of a numeric id.
Results in this output:
Does this answer your question?