Configuring MariaDB

Now that MariaDB is installed and running, we make a start on getting it configured. Our default installation of MariaDB has no root password defined, so that should be the first thing we set up. We can do this using the mysql_user module:

- name: change mysql root password  mysql_user:    name: "{{ mariadb_root_username }}"     host: "{{ item }}"     password: "{{ mariadb_root_password }}"    check_implicit_admin: "yes"    priv: "*.*:ALL,GRANT"  with_items: "{{ mariadb_hosts }}"

As you can see, we have a few different variables in use; these are defined in roles/mariadb/defaults/main.yml as:

mariadb_root_username: "root"mariadb_root_password: "Pa55W0rd123"mariadb_hosts:  - "127.0.0.1"  - "::1"  - "{{ ansible_nodename }}"  - "%" - "localhost" ...

Get Learn Ansible now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.