diff --git a/roles/cache_clear/cache_clear-opcache/defaults/main.yml b/roles/cache_clear/cache_clear-opcache/defaults/main.yml index d7f4af62..bf28c5b0 100644 --- a/roles/cache_clear/cache_clear-opcache/defaults/main.yml +++ b/roles/cache_clear/cache_clear-opcache/defaults/main.yml @@ -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 diff --git a/roles/cache_clear/cache_clear-opcache/tasks/main.yml b/roles/cache_clear/cache_clear-opcache/tasks/main.yml index 97f91ed4..56507c4a 100644 --- a/roles/cache_clear/cache_clear-opcache/tasks/main.yml +++ b/roles/cache_clear/cache_clear-opcache/tasks/main.yml @@ -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"