Files @ 5ee6fc8d3513
Branch filter:

Location: majic-ansible-roles/roles/database_server/tasks/main.yml

branko
MAR-218: Force handler execution during testing for consistency:

- Otherwise it can easily happen that some handlers never run, leaving
the machine in inconsistent state until they are run by hand.
---

- name: Install MariaDB
  ansible.builtin.apt:
    name:
      - mariadb-client
      - mariadb-server
      - python3-pymysql
    state: present

- name: Enable and start MariaDB
  ansible.builtin.service:
    name: mysql
    state: started
    enabled: true

- name: Set UTF-8 encoding as default for MariaDB
  ansible.builtin.template:
    src: "utf8.cnf.j2"
    dest: "/etc/mysql/mariadb.conf.d/90-utf8.cnf"
    owner: root
    group: root
    mode: "0644"
  register: mariadb_utf8_configuration

- name: Restart MariaDB in order to use UTF-8 as default character set  # noqa no-handler
  # [no-handler] Tasks that run when changed should likely be handlers
  #   UTF-8 configuration must be applied immediatelly in order to ensure that
  #   subsequent tasks that create databases will end-up with correct (UTF-8)
  #   encoding. Otherwise they will be created using default latin1.
  ansible.builtin.service:
    name: mysql
    state: restarted
  when: mariadb_utf8_configuration.changed

- name: Explicitly run all handlers
  ansible.builtin.include_tasks: ../handlers/main.yml
  when: "run_handlers | default(False) | bool()"
  tags:
    - handlers