Execution
Date 11 Sep 2024 15:33:23 +0100
Duration 00:01:53.14
Controller ssh-gw-4.layershift.com
User root
Versions
Ansible 2.16.4
ara 1.7.1 / 1.7.1
Python 3.10.10
Summary
138 Hosts
6 Tasks
828 Results
1 Plays
6 Files
0 Records

File: /home/ssh-gateway/ansible/kuly/check-if-mariadb.yaml

---
- name: Check
  hosts: all
  gather_facts: false
  roles:
    - plesk
  tasks:
    - name: Check if mariadb
      when: plesk_found
      block:
        - name: Check if MariaDB service is running
          ansible.builtin.systemd:
            name: mariadb
            state: started
          register: mariadb_status
          ignore_errors: true
        - name: Check if MySQL service is running
          ansible.builtin.systemd:
            name: mysql
            state: started
          when: mariadb_status is failed
          register: mysql_status
          ignore_errors: true
        - name: Set result based on service status
          ansible.builtin.set_fact:
            db_service_status: |
              {% if mariadb_status is succeeded %}
                MariaDB is running
              {% elif mysql_status is succeeded %}
                MySQL is running
              {% else %}
                Neither MariaDB nor MySQL is running
              {% endif %}
        - name: Display the database service status
          ansible.builtin.debug:
            msg: "{{ db_service_status }}"