From 9a9898f82958f2948a3a21145e3cffcd94f622ea Mon Sep 17 00:00:00 2001
From: jurgenhaas <juergen@paragon-es.de>
Date: Tue, 28 Jul 2015 17:53:38 +0200
Subject: [PATCH] Restart Apache (if present) from role PHP when needed

---
 defaults/main.yml |  1 +
 handlers/main.yml |  9 +++++++++
 tasks/php.yml     | 12 ++++++++++++
 3 files changed, 22 insertions(+)
 create mode 100644 handlers/main.yml

diff --git a/defaults/main.yml b/defaults/main.yml
index 925e9b1..80d1b67 100644
--- a/defaults/main.yml
+++ b/defaults/main.yml
@@ -1,3 +1,4 @@
+php_called_from_apache: false
 php_needs_oci8: false
 php_conf_dir: 'conf.d'
 php_allow_call_time_pass_reference: 'on'
diff --git a/handlers/main.yml b/handlers/main.yml
new file mode 100644
index 0000000..37c5633
--- /dev/null
+++ b/handlers/main.yml
@@ -0,0 +1,9 @@
+---
+# file: roles/php/handlers/php.yml
+
+- name: "PHP | Restart Apache"
+  debug: msg="Need to restart Apache server"
+  when: php_called_from_apache
+  changed_when: php_called_from_apache
+  notify:
+    - "Apache | Restart Apache"
diff --git a/tasks/php.yml b/tasks/php.yml
index 06a6b63..987201f 100644
--- a/tasks/php.yml
+++ b/tasks/php.yml
@@ -18,6 +18,8 @@
     - php5-xdebug
     - php5-dev
     - php-pear
+  notify:
+    - "PHP | Restart Apache"
 
 # TODO: Upgrade APCu on Ubuntu 14.04
 # @see https://github.com/owncloud/core/issues/14175#issuecomment-74573088
@@ -31,6 +33,8 @@
     owner=root
     group=root
     mode=0644
+  notify:
+    - "PHP | Restart Apache"
 
 - name: "PHP | Cache configuration file, apc.ini"
   template:
@@ -39,6 +43,8 @@
     owner=root
     group=root
     mode=0644
+  notify:
+    - "PHP | Restart Apache"
 
 - name: "PHP | Create extra directory for browscap"
   file:
@@ -55,6 +61,8 @@
     owner=root
     group=root
   when: php_browscap
+  notify:
+    - "PHP | Restart Apache"
 
 - name: "PHP | Enable PHP modules"
   shell: php5enmod {{ item }}
@@ -62,6 +70,8 @@
     - mcrypt
     - imap
   when: php_conf_dir == 'mods-available'
+  notify:
+    - "PHP | Restart Apache"
 
 - name: "PHP | Create htdocs directory for apc status"
   file:
@@ -83,6 +93,8 @@
   when: php_needs_oci8
   ignore_errors: yes
   changed_when: oci_available.stdout != '/usr/lib/php5/20090626/pdo_oci.so'
+  notify:
+    - "PHP | Restart Apache"
 
 - include: oci.yml
   when: repository is defined and php_needs_oci8 and oci_available.stdout != '/usr/lib/php5/20090626/pdo_oci.so'
-- 
GitLab