Execution
Date 07 Nov 2025 09:39:02 +0000
Duration 00:07:31.43
Controller ssh-gw-4.layershift.com
User root
Versions
Ansible 2.16.11
ara 1.7.3 / 1.7.3
Python 3.10.10
Summary
398 Hosts
8 Tasks
3156 Results
1 Plays
1 Files
0 Records

File: /home/ssh-gateway/ansible/kuly/zz-rm10179-check-for-php-errors.yaml

---
- name: Check for PHP FPM errors using standalone script
  hosts: all
  gather_facts: false
  tasks:
    - name: Get server info
      plesk_info:
      register: plsk

    - name: On plesk server execute block
      when: plsk.plesk_found
      block:
        - name: Upload standalone FPM error check script
          ansible.builtin.copy:
            src: zz-rm10179-check-for-php-errors.sh
            dest: /root/zz-rm10179-check-for-php-errors.sh
            mode: '0755'
          changed_when: false

        - name: Execute the FPM error check script
          ansible.builtin.shell: |
            set -o pipefail
            /root/zz-rm10179-check-for-php-errors.sh --check-only
          args:
            executable: /bin/bash
          register: script_out
          failed_when: false
          changed_when: >
            (script_out.rc != 0) or
            (':warning:' in script_out.stdout) or
            (':gear:' in script_out.stdout)

        - name: Extract status summary
          ansible.builtin.set_fact:
            # Extract the main status line
            status_line: "{{ script_out.stdout | regex_search('Status: ([^\\n]+)') | default('Status: Unknown') | trim }}"

        - name: Clean up status line for output
          ansible.builtin.set_fact:
            clean_status: "{{ status_line | regex_replace('Status: ', '') | regex_replace('warning', '') | regex_replace('check', '') | regex_replace(':', '') | trim }}"

        - name: Display clean summary and save to file
          ansible.builtin.lineinfile:
            path: "/home/ssh-gateway/ansible/kuly/zz-rm10179-check-for-php-errors.txt"
            line: "{{ inventory_hostname }} - {{ clean_status }}"
            create: true
            mode: '0644'
          delegate_to: 127.0.0.1

        - name: Show detailed output when problems found
          ansible.builtin.debug:
            msg: |
              FPM Error Check Results for {{ inventory_hostname }}:
              {{ script_out.stdout }}
          when: >
            (script_out.rc != 0) or
            (':warning:' in script_out.stdout) or
            (':gear:' in script_out.stdout) or
            (':check:' in script_out.stdout and 'would fix' in script_out.stdout)

        - name: Show success message when no problems
          ansible.builtin.debug:
            msg: "No PHP FPM errors found on {{ inventory_hostname }}"
          when: >
            (script_out.rc == 0) and
            (':warning:' not in script_out.stdout) and
            (':gear:' not in script_out.stdout) and
            (':check:' not in script_out.stdout or 'No problems found' in script_out.stdout)