Skip to content
This repository was archived by the owner on Oct 8, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 6 additions & 4 deletions roles/cache_clear/cache_clear-opcache/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
---
cache_clear_opcache:
# Adapter string to use as argument.
# eg.
# e.g.
# --fcgi=127.0.0.1:9000
# Leave blank to use /etc/cachetool.yml
# adapter: "--fcgi=127.0.0.1:9081" # Leave commented to automatically detect the adapter based on PHP version.
# --fcgi=/var/run/php-fpm.sock
# Provide an empty string to use /etc/cachetool.yml
# adapter: "--fcgi=127.0.0.1:9081" # Leave commented to automatically detect the adapter based on PHP version.
unix_socket: false # Set to true to use automatic detection of Unix socket as set by ce-provision
# Bins to clear.
clear_opcache: true
clear_apcu: false
clear_stat: true
# cachetool_bin: "/path/to/cachetool.phar" # see _init for paths if undefined
# cachetool_bin: "/path/to/cachetool.phar" # see _init for default paths if undefined
10 changes: 9 additions & 1 deletion roles/cache_clear/cache_clear-opcache/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,18 @@
executable: /bin/bash
register: _php_version

- name: Set cachetool adapter.
- name: Set cachetool adapter specified or default to a TCP/IP port.
ansible.builtin.set_fact:
_cachetool_adapter: "{{ cache_clear_opcache.adapter | default('--fcgi=127.0.0.1:90' + _php_version.stdout | replace('.','')) }}"

- name: Override cachetool adapter to be a Unix socket if requested.
ansible.builtin.set_fact:
_cachetool_adapter: "--fcgi=/var/run/php{{ _php_version.stdout | replace('.','') }}-fpm.sock"
when:
- cache_clear_opcache.unix_socket
- cache_clear_opcache.adapter is not defined

# cachetool_bin is set in the _init role.
- name: Clear opcache.
ansible.builtin.command:
cmd: "{{ cachetool_bin }} {{ _cachetool_adapter }} -n opcache:reset"
Expand Down