Browse Source

Fix the method to enable apache2 modules

Emmanuel Bouthenot 4 years ago
parent
commit
603c0e09e1
2 changed files with 8 additions and 23 deletions
  1. 4 6
      roles/webserver/tasks/apache2.yml
  2. 4 17
      roles/webserver/tasks/php.yml

+ 4 - 6
roles/webserver/tasks/apache2.yml

@@ -8,24 +8,22 @@
     - 'apache2'
 
 - name: 'Enable Apache2 default modules'
-  apache2_module:
-    name: '{{ item }}'
-    state: 'present'
+  shell: a2enmod '{{ item }}'
   with_items:
     - 'ssl'
     - 'rewrite'
     - 'expires'
     - 'headers'
+  changed_when: False
   tags:
     - 'web'
     - 'apache2'
 
 - name: 'Enable Apache2 default modules (Debian >= 9)'
-  apache2_module:
-    name: '{{ item }}'
-    state: 'present'
+  shell: a2enmod '{{ item }}'
   with_items:
     - 'http2'
+  changed_when: False
   when: ansible_lsb.major_release|int >= 9
   tags:
     - 'web'

+ 4 - 17
roles/webserver/tasks/php.yml

@@ -120,15 +120,8 @@
     - 'php'
 
 - name: 'Configure Apache2 modules for php-fpm{{ php_version }}'
-  apache2_module:
-    name: '{{ item.name }}'
-    state: '{{ item.state }}'
-    ignore_configcheck: '{{ item.ignore_configcheck }}'
-  with_items:
-    - {name: 'mpm_prefork', state: 'absent', ignore_configcheck: 'yes'}
-    - {name: 'mpm_event', state: 'present', ignore_configcheck: 'yes'}
-    - {name: 'php{{ php_version }}', state: 'absent', ignore_configcheck: 'no'}
-    - {name: 'proxy_fcgi', state: 'present', ignore_configcheck: 'no'}
+  shell: a2dismod php{{ php_version }} mpm_prefork ; a2enmod mpm_event proxy_fcgi
+  changed_when: False
   when: with_fpm|bool and with_apache2|bool
   notify:
       - 'Reload apache2'
@@ -137,14 +130,8 @@
     - 'php'
 
 - name: 'Configure Apache2 modules for modphp{{ php_version }}'
-  apache2_module:
-    name: '{{ item.name }}'
-    state: '{{ item.state }}'
-    ignore_configcheck: '{{ item.ignore_configcheck }}'
-  with_items:
-    - {name: 'mpm_event', state: 'absent', ignore_configcheck: 'yes'}
-    - {name: 'mpm_prefork', state: 'present', ignore_configcheck: 'yes'}
-    - {name: 'php{{ php_version }}', state: 'present', ignore_configcheck: 'no'}
+  shell: a2dismod mpm_event ; a2enmod mpm_prefork php{{ php_version }}
+  changed_when: False
   when: with_modphp|bool
   notify:
       - 'Reload apache2'