It seems to me that making this data queryable, would certainly
useful, but I'm trying to suss out if it is technically feasible.
We know that /var/lib/puppet/state/classes.txt contains a full list of
classes that are applied against the node. (vs. the classes foreman is
aware of through the ENC feature).
I'm wondering if there is any sane approach to get the puppet master
to upload that data to Foreman during the puppet run. In the past, we
extended the ENC script to include facts upload, but I don't think
there is an easy approach here.
The unfortunate fact is classes.txt is generated during a puppetrun,
however so are the puppet reports? (I'm feeling like a good general
solution should just touch foreman and the puppetmaster(s), and not
require client tweaks.)