---

# ---
# MySQL / MariaDB  Server
# ---

- name: Populate service facts
  ansible.builtin.service_facts:

#- name: Print service facts
#  ansible.builtin.debug:
#    var: ansible_facts.services
#  when: 
#    - ansible_facts['services']['mariadb.service']['name'] | default('not-found') != 'not-found'


- name: (mysql.yml) Ensure directory '/etc/systemd/system/mariadb.service.d' is present
  file:
    path: /etc/systemd/system/mariadb.service.d
    state: directory
    owner: root
    group: root
    mode: '0755'
  when:
    - ansible_facts['services']['mariadb.service']['name'] | default('not-found') != 'not-found'


- name: (mysql.yml) Ensure file '/etc/systemd/system/mariadb.service.d/limits.conf' exists
  copy:
    src: 'etc/systemd/system/mariadb.service.d/limits.conf'
    dest: '/etc/systemd/system/mariadb.service.d/limits.conf'
    owner: root
    group: root
    mode: '0644'
  notify: "Restart mariadb"
  when:
    - ansible_facts['services']['mariadb.service']['name'] | default('not-found') != 'not-found'
