diff --git a/CHANGES.rst b/CHANGES.rst index 2450d1a..34d6b42 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -12,7 +12,7 @@ The current role maintainer_ is ypid_. debops.apache v0.1.0 - unreleased ----------------------------------------- +--------------------------------- Added ~~~~~ @@ -66,6 +66,9 @@ Fixed for :envvar:`apache__ocsp_stapling_cache`. Before, the ``socache_shmcb`` module was implicitly loaded by the ``ssl`` module. [ypid_] +- Ensure that the rewrite module is loaded when it is used by the configuration + generated by the role. [ypid_] + - Fix ``item.https_enabled`` support for virtual hosts. This variable was ignored previously using the global default (``True``) directly. [ypid_] diff --git a/defaults/main.yml b/defaults/main.yml index 91de4c2..c0b573b 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -333,6 +333,11 @@ apache__role_modules: enabled: '{{ True if (apache__status_enabled|bool and apache__status_allow_localhost) + else omit }}' + 'rewrite': + enabled: '{{ True + if (apache__register_mod_rewrite_used is defined and + apache__register_mod_rewrite_used.rc|d(1) == 0) else omit }}' # ]]] diff --git a/tasks/main.yml b/tasks/main.yml index 38ee045..710f053 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -11,7 +11,6 @@ - '{{ apache__dependent_packages }}' # Manage Apache modules [[[1 - - name: Get list of available modules find: file_type: 'file' @@ -25,19 +24,7 @@ apache__tpl_available_modules: '{{ apache__register_mods_available.files|d({}) | map(attribute="path") | map("replace", apache__config_path + "/mods-available/", "") | map("regex_replace", "\.load$", "") | list }}' tags: [ 'role::apache:modules' ] -- name: Enable/disable Apache modules - apache2_module: - name: '{{ item.key }}' - state: '{{ (item.value.enabled - if (item.value is mapping) - else item.value) | bool | ternary("present", "absent") }}' - force: '{{ item.value.force|d(False) | bool }}' - notify: [ 'Test apache and reload' ] - when: (item.key in apache__tpl_available_modules - and item.value.enabled|d(True) != omit - and apache__deploy_state == "present") - with_dict: '{{ apache__combined_modules }}' - tags: [ 'role::apache:modules' ] +- include: apache_module_state.yml # Manage Apache configuration snippets [[[1 - name: Divert conf-available configuration @@ -137,3 +124,15 @@ when: (item.type|d(apache__vhost_type) not in ["divert"]) with_flattened: '{{ apache__combined_vhosts }}' tags: [ 'role::apache:vhosts' ] + + +# Manage Apache modules, part 2 [[[1 +- name: Detect if the rewrite module has been used in the active configuration + shell: grep --ignore-case '^\s*RewriteEngine On' {{ apache__config_path | quote }}/sites-enabled/* {{ apache__config_path | quote }}/conf-enabled/* + register: apache__register_mod_rewrite_used + always_run: True + failed_when: apache__register_mod_rewrite_used.rc not in [ 0, 1 ] + changed_when: False + when: apache__register_mod_rewrite_used is undefined + +- include: apache_module_state.yml