From 11d66cfda7047119425793db37004ba6e79f4165 Mon Sep 17 00:00:00 2001 From: Skyler Berg Date: Thu, 20 Nov 2014 15:37:14 -0800 Subject: [PATCH] Add ability to specify modules in pillar --- README.rst | 5 +++++ apache/modules.sls | 28 ++++++++++++++++++++++++++++ pillar.example | 7 +++++++ 3 files changed, 40 insertions(+) create mode 100644 apache/modules.sls diff --git a/README.rst b/README.rst index 7b1b56f..f44ee42 100644 --- a/README.rst +++ b/README.rst @@ -20,6 +20,11 @@ Available states Installs the Apache package and starts the service. +``apache.modules`` +------------------ + +Enables and disables Apache modules. + ``apache.mod_proxy`` ------------------- diff --git a/apache/modules.sls b/apache/modules.sls new file mode 100644 index 0000000..67222e7 --- /dev/null +++ b/apache/modules.sls @@ -0,0 +1,28 @@ +{% if grains['os_family']=="Debian" %} + +include: + - apache + +{% for module in salt['pillar.get']('apache:modules:enabled', []) %} +a2enmod {{ module }}: + cmd.run: + - unless: ls /etc/apache2/mods-enabled/{{ module }}.load + - order: 225 + - require: + - pkg: apache + - watch_in: + - module: apache-restart +{% endfor %} + +{% for module in salt['pillar.get']('apache:modules:disabled', []) %} +a2dismod {{ module }}: + cmd.run: + - onlyif: ls /etc/apache2/mods-enabled/{{ module }}.load + - order: 225 + - require: + - pkg: apache + - watch_in: + - module: apache-restart +{% endfor %} + +{% endif %} diff --git a/pillar.example b/pillar.example index 4745562..03a463a 100644 --- a/pillar.example +++ b/pillar.example @@ -68,3 +68,10 @@ apache: name: 'my name' path: 'salt://path/to/sites-available/conf/file' state: 'enabled' + + modules: + enabled: # List modules to enable + - ldap + - ssl + disabled: # List modules to disable + - rewrite