From 97a98fe24e95a637bced55e579f8582bec2d041e Mon Sep 17 00:00:00 2001
From: Robin Sonnabend <robin@fsmpi.rwth-aachen.de>
Date: Tue, 20 Mar 2018 20:25:13 +0100
Subject: [PATCH] Replace uwsgi-php by php-fpm for zabbix-frontend

---
 zabbix-frontend/files/10-uwsgi.conf  |  2 -
 zabbix-frontend/files/10-zabbix.conf |  1 -
 zabbix-frontend/handlers/main.yml    |  2 +-
 zabbix-frontend/meta/main.yml        |  2 +-
 zabbix-frontend/tasks/main.yml       | 71 ----------------------------
 5 files changed, 2 insertions(+), 76 deletions(-)
 delete mode 100644 zabbix-frontend/files/10-uwsgi.conf
 delete mode 100644 zabbix-frontend/files/10-zabbix.conf

diff --git a/zabbix-frontend/files/10-uwsgi.conf b/zabbix-frontend/files/10-uwsgi.conf
deleted file mode 100644
index 50b2862..0000000
--- a/zabbix-frontend/files/10-uwsgi.conf
+++ /dev/null
@@ -1,2 +0,0 @@
-d /run/uwsgi 0755 root root - -
-d /run/uwsgi/app 0755 root root - -
diff --git a/zabbix-frontend/files/10-zabbix.conf b/zabbix-frontend/files/10-zabbix.conf
deleted file mode 100644
index 4affeae..0000000
--- a/zabbix-frontend/files/10-zabbix.conf
+++ /dev/null
@@ -1 +0,0 @@
-d /run/uwsgi/app/zabbix 0775 zabbix zabbix - -
diff --git a/zabbix-frontend/handlers/main.yml b/zabbix-frontend/handlers/main.yml
index 6384a25..8f871da 100644
--- a/zabbix-frontend/handlers/main.yml
+++ b/zabbix-frontend/handlers/main.yml
@@ -1,7 +1,7 @@
 ---
 
 - name: restart zabbix frontend
-  service: name=zabbix-frontend state=restarted
+  systemd: name=php7.0-fpm.service state=restarted
 
 - name: create tmpfiles
   command: systemd-tmpfiles --create
diff --git a/zabbix-frontend/meta/main.yml b/zabbix-frontend/meta/main.yml
index 6e36713..76d5cae 100644
--- a/zabbix-frontend/meta/main.yml
+++ b/zabbix-frontend/meta/main.yml
@@ -2,5 +2,5 @@
 dependencies:
   - role: zabbix-repo
   - role: webserver
-  - role: uwsgi-php
+  - { role: php-fpm, fpm_pool: zabbix, fpm_user: zabbix, fpm_group: zabbix, fpm_socket_user: zabbix, fpm_socket_group: www-data, fpm_params: { date.timezone: "Europe/Berlin", post_max_size: "16M", max_execution_time: 300, max_input_time: 300, always_populate_raw_post_data: -1 } }
 # TODO webserver fails ansible on initial deployment currently by purpose
diff --git a/zabbix-frontend/tasks/main.yml b/zabbix-frontend/tasks/main.yml
index 08bae50..9340c5b 100644
--- a/zabbix-frontend/tasks/main.yml
+++ b/zabbix-frontend/tasks/main.yml
@@ -1,30 +1,5 @@
 ---
 
-- name: ensure there is an uwsgi temporary directory
-  copy: src=10-uwsgi.conf dest=/etc/tmpfiles.d/10-uwsgi.conf
-  notify:
-    - create tmpfiles
-  tags:
-    - config
-    - zabbix
-
-- name: ensure there is an frontend app temporary directory
-  copy: src=10-zabbix.conf dest=/etc/tmpfiles.d/10-zabbix.conf
-  notify:
-    - create tmpfiles
-  tags:
-    - config
-    - zabbix
-
-- name: ensure the systemd service file is available
-  copy: src=zabbix-frontend.service dest=/etc/systemd/system/zabbix-frontend.service
-  notify:
-    - reload systemd service files
-    - restart zabbix frontend
-  tags:
-    - service
-    - zabbix
-
 - name: ensure the frontend package is installed
   apt: name=zabbix-frontend-php state=latest
   notify:
@@ -41,14 +16,6 @@
     - packages
     - zabbix
 
-- name: ensure the frontend app got some uwsgi config
-  copy: src=zabbix.ini dest=/etc/uwsgi/apps-available/zabbix.ini
-  notify:
-    - restart zabbix frontend
-  tags:
-    - config
-    - zabbix
-
 - name: ensure a user executing the app exists
   user: name=zabbix system=yes home=/usr/share/zabbix shell=/usr/sbin/nologin createhome=no group=zabbix state=present
   notify:
@@ -57,36 +24,6 @@
     - user
     - zabbix
 
-- name: ensure an nginx config file is available
-  copy: src=zabbix.conf dest=/etc/nginx/sites-available/zabbix.conf
-  when: zabbix_configure_webserver
-  notify:
-    - restart nginx
-  tags:
-    - config
-    - zabbix
-    - nginx
-
-- name: ensure the frontend is enabled in nginx
-  lineinfile: dest=/etc/nginx/sites-available/main line="include /etc/nginx/sites-available/zabbix.conf;" insertbefore="}"
-  when: zabbix_configure_webserver
-  notify:
-    - restart nginx
-  tags:
-    - config
-    - zabbix
-    - nginx
-
-- name: ensure the frontend configuration file is installed
-  template: src=zabbix.conf.php.j2 dest=/etc/zabbix/web/zabbix.conf.php
-  when: zabbix_configure_webserver
-  notify:
-    - restart zabbix frontend
-  tags:
-    - config
-    - zabbix
-    - nginx
-
 - name: ensure the database server listens on the external interface
   replace: dest=/etc/postgresql/9.6/main/postgresql.conf regexp="#listen_addresses = 'localhost'" replace="listen_addresses = '*'"
   notify:
@@ -106,11 +43,3 @@
     - zabbix
 
 - meta: flush_handlers
-
-- name: ensure the frontend is enabled and running
-  service: name=zabbix-frontend state=running enabled=yes
-  tags:
-    - service
-    - zabbix
-
-- meta: flush_handlers
-- 
GitLab