Skip to content

Commit

Permalink
fix: zabbix-web php configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
jon4hz committed May 7, 2024
1 parent 23f2acb commit 264e78c
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 7 deletions.
6 changes: 6 additions & 0 deletions molecule/zabbix_web/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,12 @@
- ansible_distribution_major_version >= '22'
- ansible_os_family == "Debian"

- name: Set PHP Version (Suse)
ansible.builtin.set_fact:
__php_default_version_suse: "8"
when:
- ansible_os_family == "Suse"

roles:
- role: geerlingguy.apache
when:
Expand Down
11 changes: 11 additions & 0 deletions roles/zabbix_web/handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@
enabled: true
become: true
when:
- ansible_os_family == 'Debian'
- zabbix_web_version is version('5.0', '>=')

- name: restart php-fpm
ansible.builtin.service:
name: php-fpm
state: restarted
enabled: true
become: true
when:
- ansible_os_family == 'Suse'
- zabbix_web_version is version('5.0', '>=')

- name: "clean repo files from proxy creds"
Expand Down
13 changes: 13 additions & 0 deletions roles/zabbix_web/tasks/apache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@
until: zabbix_apache_conf_install is succeeded
become: true
when: ansible_os_family == "RedHat"

- name: "Suse | Install zabbix-apache-conf"
ansible.builtin.package:
pkg: zabbix-apache-conf
state: "{{ zabbix_web_package_state }}"
update_cache: true
environment:
http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}"
https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}"
register: zabbix_apache_conf_install
until: zabbix_apache_conf_install is succeeded
become: true
when: ansible_os_family == "Suse"
tags:
- install

Expand Down
5 changes: 3 additions & 2 deletions roles/zabbix_web/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
tags:
- config

- name: "Debian | Install PHP"
- name: "Debian / Suse | Install PHP"
ansible.builtin.template:
src: php-fpm.conf.j2
dest: "{{ zabbix_php_fpm_dir }}/zabbix.conf"
Expand All @@ -90,8 +90,9 @@
become: true
when:
- zabbix_web_create_php_fpm
- ansible_os_family == "Debian"
- ansible_os_family in ["Debian", "Suse"]
notify:
- restart php-fpm-version
- restart php-fpm
tags:
- config
13 changes: 13 additions & 0 deletions roles/zabbix_web/tasks/nginx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,19 @@
until: zabbix_apache_conf_install is succeeded
become: true
when: ansible_os_family == "RedHat"

- name: "Suse | Install zabbix-nginx-conf"
ansible.builtin.package:
pkg: zabbix-nginx-conf
state: "{{ zabbix_web_package_state }}"
update_cache: true
environment:
http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}"
https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}"
register: zabbix_apache_conf_install
until: zabbix_apache_conf_install is succeeded
become: true
when: ansible_os_family == "Suse"
tags:
- install

Expand Down
4 changes: 2 additions & 2 deletions roles/zabbix_web/templates/apache_vhost.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
DirectoryIndex index.php
</IfModule>

{% if ansible_os_family == "RedHat" %}
{% if ansible_os_family in ["RedHat", "Suse"] %}
<FilesMatch \.(php|phar)$>
SetHandler "proxy:unix:{{ zabbix_php_fpm_listen }}|fcgi://localhost"
</FilesMatch>
Expand Down Expand Up @@ -118,7 +118,7 @@ SSLRandomSeed connect builtin
DirectoryIndex index.php
</IfModule>

{% if ansible_os_family == "RedHat" %}
{% if ansible_os_family in ["RedHat", "Suse"] %}
<FilesMatch \.(php|phar)$>
SetHandler "proxy:unix:{{ zabbix_php_fpm_listen }}|fcgi://localhost"
</FilesMatch>
Expand Down
2 changes: 1 addition & 1 deletion roles/zabbix_web/templates/php-fpm.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ user = {{ zabbix_php_fpm_conf_user if zabbix_php_fpm_conf_user is defined else z
group = {{ zabbix_php_fpm_conf_group if zabbix_php_fpm_conf_group is defined else zabbix_web_group }}

listen = {{ zabbix_php_fpm_listen }}
{% if zabbix_php_fpm_conf_listen and ansible_os_family != 'Debian' %}
{% if zabbix_php_fpm_conf_listen and ansible_os_family not in ['Debian', 'Suse'] %}
listen.acl_users = {{ zabbix_php_fpm_conf_user if zabbix_php_fpm_conf_user is defined else zabbix_web_user }}
{% endif %}
listen.owner = {{ zabbix_php_fpm_conf_user if zabbix_php_fpm_conf_user is defined else zabbix_web_user }}
Expand Down
4 changes: 2 additions & 2 deletions roles/zabbix_web/vars/Suse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ _apache_log: apache2
_apache_service: apache2
_apache_vhost_location: /etc/apache2/conf.d/zabbix.conf

_php_fpm_dir: /etc/php-fpm.d
_php_fpm_session: /var/lib/php/session
_php_fpm_dir: "/etc/php8/fpm/php-fpm.d"
_php_fpm_session: /var/lib/php8/sessions
_zabbix_php_fpm_listen: /run/php-fpm/zabbix.sock

_nginx_user: nginx
Expand Down

0 comments on commit 264e78c

Please sign in to comment.