saltstack-formulas / apache-formula

Set up and configure the Apache HTTP server
http://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html
Other
50 stars 284 forks source link

modules section does not affect settings #265

Open grimaz opened 5 years ago

grimaz commented 5 years ago
# ``apache`` formula configuration:
apache:
  manage_service_states: True
...
  modules:
    enabled:  # List modules to enable
      - rewrite
    disabled:
      - status
...

SSH minion: Ubuntu 16.04.5 LTS

/etc/apache2/mods-enabled# ls -ls
0 lrwxrwxrwx 1 root root 36 Sep  3 07:08 access_compat.load -> ../mods-available/access_compat.load
0 lrwxrwxrwx 1 root root 28 Sep  3 07:08 alias.conf -> ../mods-available/alias.conf
0 lrwxrwxrwx 1 root root 28 Sep  3 07:08 alias.load -> ../mods-available/alias.load
0 lrwxrwxrwx 1 root root 33 Sep  3 07:08 auth_basic.load -> ../mods-available/auth_basic.load
0 lrwxrwxrwx 1 root root 33 Sep  3 07:08 authn_core.load -> ../mods-available/authn_core.load
0 lrwxrwxrwx 1 root root 33 Sep  3 07:08 authn_file.load -> ../mods-available/authn_file.load
0 lrwxrwxrwx 1 root root 33 Sep  3 07:08 authz_core.load -> ../mods-available/authz_core.load
0 lrwxrwxrwx 1 root root 33 Sep  3 07:08 authz_host.load -> ../mods-available/authz_host.load
0 lrwxrwxrwx 1 root root 33 Sep  3 07:08 authz_user.load -> ../mods-available/authz_user.load
0 lrwxrwxrwx 1 root root 32 Sep  3 07:08 autoindex.conf -> ../mods-available/autoindex.conf
0 lrwxrwxrwx 1 root root 32 Sep  3 07:08 autoindex.load -> ../mods-available/autoindex.load
0 lrwxrwxrwx 1 root root 30 Sep  3 07:08 deflate.conf -> ../mods-available/deflate.conf
0 lrwxrwxrwx 1 root root 30 Sep  3 07:08 deflate.load -> ../mods-available/deflate.load
0 lrwxrwxrwx 1 root root 26 Sep  3 07:08 dir.conf -> ../mods-available/dir.conf
0 lrwxrwxrwx 1 root root 26 Sep  3 07:08 dir.load -> ../mods-available/dir.load
0 lrwxrwxrwx 1 root root 26 Sep  3 07:08 env.load -> ../mods-available/env.load
0 lrwxrwxrwx 1 root root 29 Sep  3 07:08 filter.load -> ../mods-available/filter.load
0 lrwxrwxrwx 1 root root 27 Sep  3 07:08 mime.conf -> ../mods-available/mime.conf
0 lrwxrwxrwx 1 root root 27 Sep  3 07:08 mime.load -> ../mods-available/mime.load
0 lrwxrwxrwx 1 root root 32 Sep  3 07:08 mpm_event.conf -> ../mods-available/mpm_event.conf
0 lrwxrwxrwx 1 root root 32 Sep  3 07:08 mpm_event.load -> ../mods-available/mpm_event.load
0 lrwxrwxrwx 1 root root 34 Sep  3 07:08 negotiation.conf -> ../mods-available/negotiation.conf
0 lrwxrwxrwx 1 root root 34 Sep  3 07:08 negotiation.load -> ../mods-available/negotiation.load
0 lrwxrwxrwx 1 root root 31 Sep  3 07:08 setenvif.conf -> ../mods-available/setenvif.conf
0 lrwxrwxrwx 1 root root 31 Sep  3 07:08 setenvif.load -> ../mods-available/setenvif.load
0 lrwxrwxrwx 1 root root 29 Sep  3 07:08 status.conf -> ../mods-available/status.conf
0 lrwxrwxrwx 1 root root 29 Sep  3 07:08 status.load -> ../mods-available/status.load
jholloway7 commented 4 years ago

This works for me, but in my journey to get it to work, I think I may have had the same initial confusion.

Are you making sure to include apache.modules somewhere in your state tree? As far as I've seen, simply adding the apache:modules pillar config doesn't affect anything without also including apache.modules to instruct the formula to actually do something with it.

include:
  - apache
  - apache.config
  - apache.modules

You might think simply doing this:

include:
  - apache

Would install apache, look at the pillar to see what else has been configured, and then include that as well. I'm just guessing, but I don't think most formulas do that because then providing 'default' values is more complex and forces assumptions about which pieces the developer wants to use.

In other words, the developer wouldn't be able to pick and choose which states to use without further complicating configuration. For example, someone might want to use this formula to install apache and enable certain modules, but then manage their config files outside the formula. What you choose to include is how you as the developer controls such decisions.