Execution
Date 28 Apr 2026 08:25:10 +0100
Duration 00:05:01.78
Controller ssh-gw-4.layershift.com
User root
Versions
Ansible 2.16.13
ara 1.7.5 / 1.7.5
Python 3.10.10
Summary
394 Hosts
5 Tasks
1958 Results
1 Plays
1 Files
0 Records

File: /home/ssh-gateway/ansible/kuly/zz-detect-opcache-issues.yaml

---
- name: Detect servers with missing alt-php opcache modules
  hosts: all
  gather_facts: false
  vars:
    php_versions:
      - "54"
      - "55"
      - "56"
    affected_versions: []

  tasks:
    - name: Get server info
      plesk_info:
      register: plsk
      ignore_errors: true

    - name: Check PHP versions for opcache errors
      when: plsk.plesk_found
      block:
        - name: Run php command
          ansible.builtin.command: "/opt/alt/php{{ item }}/usr/bin/php -m"
          loop: "{{ php_versions }}"
          register: php_checks
          failed_when: false
          changed_when: false

        - name: Identify affected versions on this host
          ansible.builtin.set_fact:
            affected_versions: "{{ affected_versions + [item.item] }}"
          loop: "{{ php_checks.results }}"
          when: >-
            item.stderr is defined and
            'cannot open shared object file' in item.stderr and
            'opcache.so' in item.stderr

        - name: Report if any version is affected
          ansible.builtin.debug:
            msg: |
              ⚠️  HOST {{ inventory_hostname }} HAS MISSING OPCACHE:
              → Affected PHP versions: {{ affected_versions }}
              → Run: dnf install alt-php{{ affected_versions | join(' alt-php') }}-opcache
          when: affected_versions | length > 0
          changed_when: true

        - name: Report clean host
          ansible.builtin.debug:
            msg: "✓ {{ inventory_hostname }}: All checked PHP versions have opcache loaded correctly"
          when: affected_versions | length == 0