For a while now, I've been bothered with certain aspects of foreman on
how puppet classes are imported. Mainly 2 things make me twitch:
-
There are a lot of classes imported that are not meant to be used
directly. They are included somewhere in the module rather to split
code up and keep it neat. Removing them manually after the import can
be tedious and time consuming, especially if you have to do it
multiple times. -
Setting up each parameter for a class is bothersome: time-consuming
and the information should be defined in the puppet module rather than
duplicated each time within foreman.
A solution to this is pretty straightforward: we define a file within
our module which contains this metadata.
The ignoring part is something that is easily implemented since all
code is on the smart-proxy side. For exposing additional parameter
information, more work will have to be done - also on the foreman
side. I doubt I'll manage this on my own
I've started coding on a solution for the first problem and came up
with something that works. The first problem is: what do we call this
meta-file. I've thought about .foreman.yaml which makes it a hidden
file by default, but I'm no longer sure this is the best approach. The
puppet forge module file isn't hidden and the meta information is
typically something we DO want to redistribute so maybe Foreman.meta
or Modulemeta or … is a better name (open for suggestions on this
part).
My example implementation meta file looks like:
- — SNIPPET —
Ignore these classes.
Prevents the proxy from exposing them in the api.
proxy_ignore_files:
- ignore/*
proxy_ignore_classes:
-
foo::*
-
— SNIPPET —
Alternatively, you can also use values like "!ruby/regexp '/^foo::./'".
Regular strings get 'converted' to regexpes by replacing '' by '.*?'.
There are 2 different keys that work on different levels. To make
things clearer, I would like to choose one of these and stick with that.
The ignore_files has the advantage that it actually does not parse
files that match it. So it kinda speeds things up. ignore_classes
could be useful for times where you define multiple classes in a
single file and only want to exclude some. Since this would break the
'puppet autoloader layout', I'm not sure we need this.
I could refactor to have one proxy_ignore which checks for matches
against files and classes.
So, basically, the request for comment is on the following subjects:
How do we name a file which contains the meta? Currently only to
ignore stuff, but indication what type, validation, … a parameter
takes could be added in the future.
What do we ignore. Files? or Classes? or both?
If both, do we migrate to one key with a small impact on performance
(we filter more records twice).
Future wise, what could be a good hierarchy for storing additional
parameter information?
Note:
Cheers
Jan.