Skip to content
Snippets Groups Projects
Verified Commit 8621455a authored by Chris Croome's avatar Chris Croome
Browse files

Only restart PHP-FPM when init system is systemd

parent bda6c288
No related branches found
No related tags found
1 merge request!1Merge Sury
Pipeline #26640 failed
# Copyright 2019-2023 Chris Croome
#
# This file is part of the Webarchitects PHP Ansible role.
#
# The Webarchitects PHP Ansible role is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
#
# The Webarchitects PHP Ansible role is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with the Webarchitects PHP Ansible role. If not, see <https://www.gnu.org/licenses/>.
---
- name: Check the init system
block:
# When in a docker container php_init.stdout == "sh"
- name: Check if system has been booted with systemd as init system
ansible.builtin.command: ps -p 1 -o comm=
changed_when: false
check_mode: false
register: php_ps
failed_when: php_ps.rc is not regex('^0|47$')
- name: Set a fact for the init system
ansible.builtin.set_fact:
php_init: "{{ php_ps.stdout }}"
when: php_ps.rc == 0
- name: When the exit code is 47 assume is is because this is a chroot
ansible.builtin.set_fact:
php_init: "{{ php_ps.stdout }}"
when: php_ps.rc == 47
- name: Debug the ini system
ansible.builtin.debug:
var: php_init
verbosity: "{% if ansible_check_mode | bool %}0{% else %}1{% endif %}"
tags:
- php
...
......@@ -110,7 +110,7 @@
owner: root
group: root
- name: Test and reload PHP configuration file when file is in a FPM directory
- name: Test and reload PHP configuration file when file is in a FPM directory and the init system is systemd
block:
- name: Test PHP configuration
......@@ -159,6 +159,7 @@
state: reloaded
when:
- php_init == "systemd"
- php_conf_file_version in php_ver_installed
- php_conf_file_changed | bool
- php_conf_file_sapi is defined
......
......@@ -64,7 +64,7 @@
group: root
register: php_conf_file_templated
- name: Test and reload PHP configuration file when file is in a FPM directory
- name: Test and reload PHP configuration file when file is in a FPM directory and the init system is systemd
block:
- name: Test PHP configuration
......@@ -113,6 +113,7 @@
state: reloaded
when:
- php_init == "systemd"
- php_conf_file_version is defined
- php_conf_file_version in php_ver_installed
- php_conf_file_templated.changed is defined
......
......@@ -43,6 +43,15 @@
- php_cfg
- php_conf
- name: Include the init system check tasks
ansible.builtin.include_tasks: check_vars.yml
tags:
- php_apt
- php_cfg
- php_conf
- php_mods
- php_pkg
- name: Include Sury PHP apt repo tasks
ansible.builtin.include_tasks: apt.yml
when: php_sury is defined
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment