Skip to content

Commit

Permalink
Ensure that the rewrite module is loaded when required by the role
Browse files Browse the repository at this point in the history
  • Loading branch information
ypid committed Feb 7, 2017
1 parent b1231f7 commit c90da65
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
5 changes: 4 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The current role maintainer_ is ypid_.


debops.apache v0.1.0 - unreleased
----------------------------------------
---------------------------------

Added
~~~~~
Expand Down Expand Up @@ -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_]

Expand Down
5 changes: 5 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}'

# ]]]
Expand Down
27 changes: 13 additions & 14 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
- '{{ apache__dependent_packages }}'

# Manage Apache modules [[[1

- name: Get list of available modules
find:
file_type: 'file'
Expand All @@ -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
Expand Down Expand Up @@ -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

0 comments on commit c90da65

Please sign in to comment.