Skip to content

Commit c90da65

Browse files
committed
Ensure that the rewrite module is loaded when required by the role
1 parent b1231f7 commit c90da65

File tree

3 files changed

+22
-15
lines changed

3 files changed

+22
-15
lines changed

CHANGES.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ The current role maintainer_ is ypid_.
1212

1313

1414
debops.apache v0.1.0 - unreleased
15-
----------------------------------------
15+
---------------------------------
1616

1717
Added
1818
~~~~~
@@ -66,6 +66,9 @@ Fixed
6666
for :envvar:`apache__ocsp_stapling_cache`. Before, the ``socache_shmcb``
6767
module was implicitly loaded by the ``ssl`` module. [ypid_]
6868

69+
- Ensure that the rewrite module is loaded when it is used by the configuration
70+
generated by the role. [ypid_]
71+
6972
- Fix ``item.https_enabled`` support for virtual hosts. This variable was
7073
ignored previously using the global default (``True``) directly. [ypid_]
7174

defaults/main.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,11 @@ apache__role_modules:
333333
enabled: '{{ True
334334
if (apache__status_enabled|bool
335335
and apache__status_allow_localhost)
336+
else omit }}'
337+
'rewrite':
338+
enabled: '{{ True
339+
if (apache__register_mod_rewrite_used is defined and
340+
apache__register_mod_rewrite_used.rc|d(1) == 0)
336341
else omit }}'
337342

338343
# ]]]

tasks/main.yml

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
- '{{ apache__dependent_packages }}'
1212

1313
# Manage Apache modules [[[1
14-
1514
- name: Get list of available modules
1615
find:
1716
file_type: 'file'
@@ -25,19 +24,7 @@
2524
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 }}'
2625
tags: [ 'role::apache:modules' ]
2726

28-
- name: Enable/disable Apache modules
29-
apache2_module:
30-
name: '{{ item.key }}'
31-
state: '{{ (item.value.enabled
32-
if (item.value is mapping)
33-
else item.value) | bool | ternary("present", "absent") }}'
34-
force: '{{ item.value.force|d(False) | bool }}'
35-
notify: [ 'Test apache and reload' ]
36-
when: (item.key in apache__tpl_available_modules
37-
and item.value.enabled|d(True) != omit
38-
and apache__deploy_state == "present")
39-
with_dict: '{{ apache__combined_modules }}'
40-
tags: [ 'role::apache:modules' ]
27+
- include: apache_module_state.yml
4128

4229
# Manage Apache configuration snippets [[[1
4330
- name: Divert conf-available configuration
@@ -137,3 +124,15 @@
137124
when: (item.type|d(apache__vhost_type) not in ["divert"])
138125
with_flattened: '{{ apache__combined_vhosts }}'
139126
tags: [ 'role::apache:vhosts' ]
127+
128+
129+
# Manage Apache modules, part 2 [[[1
130+
- name: Detect if the rewrite module has been used in the active configuration
131+
shell: grep --ignore-case '^\s*RewriteEngine On' {{ apache__config_path | quote }}/sites-enabled/* {{ apache__config_path | quote }}/conf-enabled/*
132+
register: apache__register_mod_rewrite_used
133+
always_run: True
134+
failed_when: apache__register_mod_rewrite_used.rc not in [ 0, 1 ]
135+
changed_when: False
136+
when: apache__register_mod_rewrite_used is undefined
137+
138+
- include: apache_module_state.yml

0 commit comments

Comments
 (0)