This repository contains an Ansible role for installing [MariaDB](https://mariadb.org/) on Debian servers, it requires a recent version of the [community.mysql collection](https://docs.ansible.com/ansible/latest/collections/community/mysql/), this can be installed into `~/.ansible/collections/ansible_collections` like this:
See the [defaults/main.yml](defaults/main.yml) for the options that can be set.
To use this role you need to use Ansible Galaxy to install it into another repository under `galaxy/roles/mariadb` by adding a `requirements.yml` file in that repo that contains:
```yml
---
- name: mariadb
src: https://git.coop/webarch/mariadb.git
version: master
scm: git
```
And a `ansible.cfg` that contains:
```
[defaults]
retry_files_enabled = False
pipelining = True
inventory = hosts.yml
roles_path = galaxy/roles
```
And a `.gitignore` containing:
```
roles/galaxy
```
To pull this repo in run:
This repository contains an Ansible role for installing and configuring [MariaDB](https://mariadb.org/) on Debian servers.
The other repo should also contain a `mariadb.yml` file that contains:
```yml
---
-name:Install MariaDB
become:yes
hosts:
-mariadb_servers
roles:
-mariadb
```
And a `hosts.yml` file that contains lists of servers, for example:
Versions of this role including and prior to [version 1.9.1](https://git.coop/webarch/mariadb/-/tree/1.9.1) require Ansible 2.9 and use the command and shell modules for many tasks, version 2.0.0 onwards uses the [community.mysql collection](https://docs.ansible.com/ansible/latest/collections/community/mysql/).
```yml
---
all:
children:
mariadb_servers:
hosts:
host3.example.org:
host4.example.org:
cloud.example.com:
cloud.example.org:
cloud.example.net:
```
Then it can be run as follows:
The `community.mysql` collection modules can be installed into `~/.ansible/collections/ansible_collections` like this:
```bash
ansible-playbook mariadb.yml
ansible-galaxy collection install community.mysql
```
## Creating multiple users and databases
This role can be used to switch the root users authentication plugin from `unix_socket` to `mysql_native_password` and back and it also imports the sysc schem, updates the timezone data when needed and sets some systemd defaults.
## Defaults
See also the [defaults/main.yml](defaults/main.yml) file.
| `mariadb` | `true` | Set `mariadb` to false to prevent any tasks in this role being run |
| `mariadb_host` | `localhost` | Note that this roles hasn't been tested with hosts other than `localhost` |
| `mariadb_port` | `3306` | The default MariaDB port |
| `mariadb_path` | `/usr/bin/mariadb` | The existance of the `mariadb_path` is used as a test for generating the `local_facts` |
| `mariadb_socket` | `/var/run/mysqld/mysqld.sock` | The path to the MariaDB scoket |
| `mariadb_sys_schema` | `true` | If `mariadb_sys_schema` is true then the sys schema is imported from [this repo](https://github.com/webarch-coop/mariadb-sys) |
| `mariadb_time_zone_import` | `true` | If `mariadb_time_zone_import` is true then the time zone tables when they have been updated |
| `mariadb_systemd_no_new_privileges` | `true` | Set systemd `NoNewPrivileges` to true for MariaDB |
| `mariadb_systemd_private_network` | `true` | Set systemd `PrivateNetwork` to true for MariaDB |
| `mariadb_systemd_private_tmp` | `true` | Set systemd `PrivateTmp` to true for MariaDB |