Introduce more variables

This commit is contained in:
phil 2023-02-25 21:25:34 +01:00
parent cfdc088844
commit 4bb9eb3870
4 changed files with 23 additions and 23 deletions

View file

@ -1,3 +1,8 @@
---
php_fpm_log_dir: /var/log/phpfpm
php_fpm_pool_dir: "/etc/php/{{ php_version.stdout }}/fpm/pool.d"
php_fpm_pool_config_file: "{{ php_fpm_pool_dir }}/%i.cfg"
php_fpm_cpu_quota: "100%"
php_fpm_memory_high: "25%"
php_fpm_memory_max: "35%"

View file

@ -39,21 +39,14 @@
when: "'php-fpm' in ansible_facts.packages"
notify: reload php-fpm
- name: "PHP | Copy template for PHP-FPM systemd socket"
ansible.builtin.copy:
src: systemd/php-fpm@.socket
dest: /etc/systemd/system/php-fpm@.socket
mode: 0644
notify:
- stop php-fpm-socket
- stop php-fpm-service
- start php-fpm-socket
- name: "PHP | Copy template for PHP-FPM systemd service"
- name: "PHP | Copy template for PHP-FPM systemd service and socket"
ansible.builtin.template:
src: systemd/php-fpm@.service
dest: /etc/systemd/system/php-fpm@.service
src: "systemd/{{ item }}"
dest: "/etc/systemd/system/{{ item }}"
mode: 0644
loop:
- php-fpm@.service
- php-fpm@.socket
notify:
- stop php-fpm-socket
- stop php-fpm-service

View file

@ -1,6 +1,6 @@
# {{ ansible_managed }}
#
# This service can be enabled for user.
# This service can be enabled for each user.
# It uses a single php-fpm configuration file.
# User-specific settings can be overridden via environment variables (see "FPM_SOCKET_PATH" below).
@ -11,14 +11,14 @@ After=network.target
Requires=php-fpm@%i.socket
[Service]
User=%i
Group=%i
User={{ php_fpm_user | default('%i') }}
Group={{ php_fpm_group | default('%i') }}
Type=notify
Environment="FPM_SOCKETS=/run/php/php-fpm-%i.sock=3"
Environment="FPM_ERROR_LOG={{ php_fpm_log_dir }}/%i.log"
Environment="FPM_ERROR_LOG={{ php_fpm_log_dir }}/{{ php_fpm_log_file | default('%i.log') }}"
# this variable is used in the pool configuration file
Environment="FPM_SOCKET_PATH=/run/php/php-fpm-%i.sock"
ExecStart=/usr/sbin/php-fpm{{ php_version.stdout }} --nodaemonize --fpm-config /etc/php/{{ php_version.stdout }}/fpm/pool.d/%i.cfg
ExecStart=/usr/sbin/php-fpm{{ php_version.stdout }} --nodaemonize --fpm-config {{ php_fpm_pool_config_file }}
ExecReload=/bin/kill -USR2 $MAINPID
KillMode=process
Restart=on-failure
@ -51,9 +51,9 @@ RuntimeDirectory=php
RuntimeDirectoryPreserve=yes
# Resources
CPUQuota=100%
MemoryHigh=25%
MemoryMax=35%
CPUQuota={{ php_fpm_cpu_quota }}
MemoryHigh={{ php_fpm_memory_high }}
MemoryMax={{ php_fpm_memory_max }}
[Install]
WantedBy=multi-user.target

View file

@ -1,9 +1,11 @@
# {{ ansible_managed }}
[Unit]
After=network-online.target
[Socket]
SocketUser=%i
SocketGroup=%i
SocketUser={{ php_fpm_socket_user | default('%i') }}
SocketGroup={{ php_fpm_socket_group | default('%i') }}
SocketMode=0660
ListenStream=/run/php/php-fpm-%i.sock