Skip to content

correct logrotate permissions #472

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: rocky-master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions roles/cs.php-fpm/tasks/004-logrotate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
- name: Ensure PHP-FPM log directory has correct permissions
file:
path: /var/log/php-fpm
state: directory
owner: root
group: root
mode: '0755'
when: ansible_os_family == "RedHat"

- name: Create PHP-FPM logrotate configuration
template:
src: php-fpm.logrotate.conf.j2
dest: /etc/logrotate.d/php-fpm
owner: root
group: root
mode: '0644'

2 changes: 2 additions & 0 deletions roles/cs.php-fpm/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
set_fact:
php_fpm_pm_max_children_default: "{{ [ [ php_fpm_pm_max_children_by_memory | int, php_fpm_pm_max_children_by_cpu | int ] | min, 4 ] | max }}"

- import_tasks: 004-logrotate.yml

- name: Calculate workers
set_fact:
php_fpm_pm_max_children: "{{ php_fpm_pm_max_children | default(php_fpm_pm_max_children_default, true) }}"
Expand Down
13 changes: 13 additions & 0 deletions roles/cs.php-fpm/templates/php-fpm.logrotate.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/var/log/php-fpm/*.log {
missingok
notifempty
daily
rotate 14
compress
delaycompress
create 0640 root root
sharedscripts
postrotate
/bin/kill -SIGUSR1 $(cat /var/run/php-fpm/php-fpm.pid 2>/dev/null) 2>/dev/null || true
endscript
}