|
10 | 10 | - '{{ apache__packages }}'
|
11 | 11 | - '{{ apache__dependent_packages }}'
|
12 | 12 |
|
13 |
| -# Manage Apache modules [[[1 |
14 |
| - |
15 |
| -- name: Get list of available modules |
16 |
| - find: |
17 |
| - file_type: 'file' |
18 |
| - paths: [ '{{ apache__config_path + "/mods-available/" }}' ] |
19 |
| - patterns: [ '*.load' ] |
20 |
| - register: apache__register_mods_available |
21 |
| - tags: [ 'role::apache:modules' ] |
22 |
| - |
23 |
| -- name: Set list of available modules |
24 |
| - set_fact: |
25 |
| - 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 }}' |
26 |
| - tags: [ 'role::apache:modules' ] |
27 |
| - |
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' ] |
41 |
| - |
42 | 13 | # Manage Apache configuration snippets [[[1
|
43 | 14 | - name: Divert conf-available configuration
|
44 | 15 | command: dpkg-divert --quiet --local
|
|
137 | 108 | when: (item.type|d(apache__vhost_type) not in ["divert"])
|
138 | 109 | with_flattened: '{{ apache__combined_vhosts }}'
|
139 | 110 | tags: [ 'role::apache:vhosts' ]
|
| 111 | + |
| 112 | +# Manage Apache modules [[[1 |
| 113 | +- name: Detect if the rewrite module has been used in the active configuration |
| 114 | + shell: grep --ignore-case '^\s*RewriteEngine On' {{ apache__config_path | quote }}/sites-enabled/* {{ apache__config_path | quote }}/conf-enabled/* |
| 115 | + register: apache__register_mod_rewrite_used |
| 116 | + always_run: True |
| 117 | + failed_when: apache__register_mod_rewrite_used.rc not in [ 0, 1 ] |
| 118 | + changed_when: False |
| 119 | + when: apache__register_mod_rewrite_used is undefined |
| 120 | + |
| 121 | +- name: Get list of available modules |
| 122 | + find: |
| 123 | + file_type: 'file' |
| 124 | + paths: [ '{{ apache__config_path + "/mods-available/" }}' ] |
| 125 | + patterns: [ '*.load' ] |
| 126 | + register: apache__register_mods_available |
| 127 | + tags: [ 'role::apache:modules' ] |
| 128 | + |
| 129 | +- name: Set list of available modules |
| 130 | + set_fact: |
| 131 | + 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 }}' |
| 132 | + tags: [ 'role::apache:modules' ] |
| 133 | + |
| 134 | +- name: Enable/disable Apache modules |
| 135 | + apache2_module: |
| 136 | + name: '{{ item.key }}' |
| 137 | + state: '{{ (item.value.enabled |
| 138 | + if (item.value is mapping) |
| 139 | + else item.value) | bool | ternary("present", "absent") }}' |
| 140 | + force: '{{ item.value.force|d(False) | bool }}' |
| 141 | + notify: [ 'Test apache and reload' ] |
| 142 | + when: (item.key in apache__tpl_available_modules |
| 143 | + and item.value.enabled|d(True) != omit |
| 144 | + and apache__deploy_state == "present") |
| 145 | + with_dict: '{{ apache__combined_modules }}' |
| 146 | + tags: [ 'role::apache:modules' ] |
0 commit comments