-
Notifications
You must be signed in to change notification settings - Fork 1
The Final Puppetization #28
Comments
So, looked into this and there's one gotcha that has to do with the recommended way to make hiera inherit hierarchies of config files. The idea being that you could have a base config like this: in base.yaml:
and then another file that inherits from that: in derived.yaml:
the resulting config might look like:
HOPEFULLY that's what it would look like. However, the merging behavior of hiera gets a little weird occasionally and it doesn't come out clean. In addition, there's no real way to remove params from base levels too. We're currently using something called deep-merge which does a decent job of guessing the right thing. That all being said, before embarking on this, it would be worth having a conversation with @thaeli about the redis config (which would be necessary for other stuff like docker deploys) and to figure out how to do a bunch of layers of inheritance of config values there without necessarily having to use hiera for it. We're going to need to think carefully about that as our plugins become more complex too and will need their own configs tracked independently of the main config. So: TLDR: I hear what you're saying here, and we should figure out and get everyone on the same page for a comprehensive plan for config stuff. |
Two minor notes:
Strictly speaking, nothing is ever "removed" from a configspec-based ConfigObj instance. You would merely set it back to its old default value. For example, if the config:
key1: "Hello World" then in order to "unset" it, config:
key2: ""
If we do end up moving in that direction, this will be less of a big deal, but we're always going to have some ConfigObj config, for things we don't want stored in Redis like account creds for Stripe, Postrgres, AWS, and of course Redis itself. So this would still be helpful to avoid needing to individually puppetize every individual config option. |
If we move to a Docker-based deployment, some of the specifics of storing that info may change. Breaking it out into a separate ConfigObj is reasonable for now though, and will make that refactor easier. |
so I looked into two things on this recently.
the idea is the that the .erb is supposed to only work with data passed into it by the puppet class it's refernced from, so that the class can perform validations and such against it.
and that $configdata is what you're proposing like:
Then you only have to specify things in hiera. I'm only guessing that this is possible, I don't know for sure. If that does work, we just have to look into how merging an array of config data works between different levels of the hierarchy. We were doing this fine before, but with it all under one variable, could get tricky, not sure. |
Yeah, I'm guessing this would be a pretty huge amount of work, and it might just never be worth doing. I mean, it's not like it's that hard to puppetize a new option. I've just been spoiled by the fact that I used to be able to just update a config then run Again, not a huge deal and the new stuff is definitely better, but I definitely feel the difference in terms of the friction on "I'm just trying to do a thing but now I have to stop what I'm doing to go puppetize another config option". Probably not worth the tons of hours and hours required to implement this ticket, though that would be amazing if it turned out to be easy. |
btw, maybe relevant: https://forge.puppet.com/puppetlabs/inifile |
Someone implemented this where I work and it turned out to be pretty straightforward for the simple case (which wouldn't completely apply to us). If we have a
Obviously it would be a pretty big refactor to go from what we have now to taking this approach. And the difficult part which this ducks merging data from different sub-parts of the has. Still, I figured I'd post this snippet since it's at least half the battle (even if it is the easy half). |
So hey btw, the good news is -i think- all the hiera inheritance stuff happens before this is called so -in theory- integrating this with the merging shouldn't be hard, assuming the 'deep merge' strategy plays nice. which it may not. can look into it though. |
at any rate, very cool |
According to the guy who cooked up that recipe, we can use FWIW, we've never actually tested this where I work since so far all the manifests which use this pattern have defined all their options in a single YAML file and haven't needed to override default values and such through hiera data. |
At the moment, our puppet manifests suffer from the problem that if we add a config option, we need to go into our puppet manifest and template and then add it there as well, or else it isn't really configurable. Ditto for config options which are not currently tracked by Puppet; they're technically configurable, but not really.
As it happens, our configuration is currently just a giant dictionary. I mean, technically it's an ini file, but it ends up parsing to a dictionary. So instead of having a bunch of different hiera variables, each controlling a single option, I'd like to have a single dictionary which maps to the entire config. For example, if we had this yaml
that would render the following to our development.ini file
Then we could have a single nested hiera variable which will always be able to contain any/all of our config options without having to individually puppetize each one.
The text was updated successfully, but these errors were encountered: