Detect module dependencies when modules are not default-loaded
Additional Context
If you accept default_mods => true you get a -lot- of apache modules automatically. In my experience it's too many, which has led to us doing default_mods => [] to reduce the sprawl, and then adding back in what we need. That leads to a bit of whack-a-mole upon new server buildout, as a lot of this module's code assumes that you have included the default modules and it doesn't need to check. It also leads to "I'm not sure if I can remove this module" later, if you remove directives.
Summary
This covers off the worst offenders I've hit in our environment: mod_dir, mod_autoindex, mod_expires, mod_dav, and mod_cgi. If you use vhost directory parameters that will invoke these module directives, vhost will try to make sure the module is loaded. If you're on default_mods => true, this is a 'wasted' extra load; if you don't have the module loaded (say, default_mods => false) then this brings the module in for you.
Related Issues (if any)
N/A
Checklist
- [x] 🟢 Spec tests.
- [ ] 🟢 Acceptance tests.
- [x] Manually verified. (For example
puppet apply)
Should this magically load dependencies, or should it display errors so people know to correct their code? I'm not sure I have a strong opinion there. Perhaps it could load, but also print an INFO message.
There's plenty of prior art of the puppet-module "acting on your behalf" in grabbing needed apache-modules. One for a quick example: https://github.com/puppetlabs/puppetlabs-apache/blob/1c720758bf4ac605c58a1cb0e1f181566af377b8/manifests/vhost.pp#L2261-L2263 is "if your vhost directive asked for virtual_docroot (which defaults to false), jump in and grab the apache-module that will make it work." This parallels what I'm looking for: 'demand an apache module when it is needed'. The difference is that a lot of the puppet module is built on the assumption that some of the apache modules are always there... and they don't have to be. Which is actually a bit odd, since the spec test https://github.com/puppetlabs/puppetlabs-apache/blob/1c720758bf4ac605c58a1cb0e1f181566af377b8/spec/defines/vhost_spec.rb#L11 assumes default_mods => false while most of the code is built with an unspoken assumption of default_mods => true
That all happens without an INFO or an explicit apache-module declaration, so IMO autoloading the apache-modules (quietly, as needed) is the way to go here.