Skip to content

Detect module dependencies when modules are not default-loaded #2598

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

gcoxmoz
Copy link
Contributor

@gcoxmoz gcoxmoz commented Apr 4, 2025

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

  • 🟢 Spec tests.
  • 🟢 Acceptance tests.
  • Manually verified. (For example puppet apply)

@gcoxmoz gcoxmoz requested review from bastelfreak, ekohl, smortex and a team as code owners April 4, 2025 01:20
@binford2k
Copy link
Contributor

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.

@gcoxmoz
Copy link
Contributor Author

gcoxmoz commented Apr 14, 2025

There's plenty of prior art of the puppet-module "acting on your behalf" in grabbing needed apache-modules. One for a quick example:

if $virtual_docroot {
include apache::mod::vhost_alias
}
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
"class {'apache': default_vhost => false, default_mods => false, vhost_enable_dir => '/etc/#{apache_name}/sites-enabled'}"
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.

Copy link
Collaborator

@ekohl ekohl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been pushing in this direction. Like #2255 and #2337. Exactly for the reason you mention: I want to run the server with default_mods => false but not think about which modules to include.

My ideal is that we actually define a proper data type for $directories and enforce it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants