Getting started

Example inventory

To install MariaDB on a host, you need to add it to [debops_service_mariadb_server] Ansible group:

[debops_service_mariadb_server]
database-host

This will install mariadb-server package, configure the server to listen on localhost for new connections, and install automysqlbackup script to automatically create daily, weekly and monthly backups of the database.

Example playbook

Here's an example Ansible playbook that uses the debops.mariadb_server role:

---

- name: Manage MariaDB server
  collections: [ 'debops.debops', 'debops.roles01',
                 'debops.roles02', 'debops.roles03' ]
  hosts: [ 'debops_service_mariadb_server' ]
  become: True

  environment: '{{ inventory__environment | d({})
                   | combine(inventory__group_environment | d({}))
                   | combine(inventory__host_environment  | d({})) }}'

  roles:

    - role: keyring
      tags: [ 'role::keyring', 'skip::keyring', 'role::mariadb_server' ]
      keyring__dependent_apt_keys:
        - '{{ mariadb_server__keyring__dependent_apt_keys }}'

    - role: etc_services
      tags: [ 'role::etc_services' ]
      etc_services__dependent_list:
        - '{{ mariadb_server__etc_services__dependent_rules }}'

    - role: ferm
      tags: [ 'role::ferm', 'skip::ferm' ]
      ferm__dependent_rules:
        - '{{ mariadb_server__ferm__dependent_rules }}'

    - role: tcpwrappers
      tags: [ 'role::tcpwrappers', 'skip::tcpwrappers' ]
      tcpwrappers__dependent_allow:
        - '{{ mariadb_server__tcpwrappers__dependent_allow }}'

    - role: python
      tags: [ 'role::python', 'skip::python', 'role::mariadb_server' ]
      python__dependent_packages3:
        - '{{ mariadb_server__python__dependent_packages3 }}'
      python__dependent_packages2:
        - '{{ mariadb_server__python__dependent_packages2 }}'

    - role: mariadb_server
      tags: [ 'role::mariadb_server', 'skip::mariadb_server' ]

Remote access to the database

If you want to allow connections from remote hosts to the MariaDB server, you need to change the bind address to listen on all network interfaces, and specify the list of IP addresses or CIDR networks which can connect to the daemon:

mariadb_server__bind_address: '::'
mariadb_server__allow: [ '192.0.2.0/24', '2001:db8:3232::/64' ]

Changing the bind address will require the MariaDB daemon to be restarted, however debops.mariadb_server does not do that automatically to avoid disrupting the normal server operations. To restart the service, you can run this Ansible command:

user@host:~$ ansible database-host -b -m service -a 'name=mysql state=restarted'

Note the mysql service name - MariaDB still uses the old MySQL init files, configuration and data paths to allow easy compatibility with old MySQL installations.

Database and user management

debops.mariadb_server is not meant to be used to manage databases and user accounts. You should use debops.mariadb role instead, which was designed specifically for this purpose.