supertarto.mariadb

Ansible MariaDB

CI

Install and set up MariaDB using Ansible

Requirements

None

Tested Platforms

  • Debian 10 (Buster)
  • Debian 11 (Bullseye)
  • Debian 12 (Bookworm)

Role Variables

These variables help you decide whether to use a dump script, overwrite the global my.cnf file, or update the root password.

mariadb_use_dump_script: true
mariadb_overwrite_global_mycnf: true
mariadb_root_password_update: false

Here are the different paths used by MariaDB. The dump_path and dump_path_script are for storing the dump and the dump script. Make sure to back up these dumps externally. The dump script is automatically run by a cron job.

mariadb_dump_path: "/var/local/dump_sql"
mariadb_log_path: "/var/log/mariadb"
mariadb_dump_path_script: "/var/local/scripts"
mariadb_datadir: /var/lib/mariadb
mariadb_root_home: "/root"

Set the root username and password for MariaDB. Make sure to change this!

mariadb_root_username: "root"
mariadb_root_password: "defaultpass"

To create databases, you can add multiple ones. The collation and encoding fields are optional. If not specified, they will default to utf8_general_ci and utf8.

mariadb_databases: []
# Example:
# - name: database1
#   collation: utf8_general_ci
#   encoding: utf8

To create users, the host and priv fields are optional. If not set, they will default to localhost and *.*:USAGE.

mariadb_users: []
# Example:
# - name: username
#   host: localhost
#   password: sqlpassword
#   priv: "*.*:SELECT,UPDATE"

If you want to use the dump script, set these values, create the user in mariadb_users, and set the "priv" to *.*:SELECT,LOCK TABLES.

mariadb_dump_user: []
mariadb_dump_pass: []

Specify the port and bind address for MariaDB.

mariadb_port: "3306"
mariadb_bind_address: '127.0.0.1'

Define the log file paths based on the mariadb_log_path value.

mariadb_log: "{{ mariadb_log_path }}/mariadb.log"
mariadb_log_error: "{{ mariadb_log_path }}/mariadb.err"

Default character set and collation.

mariadb_character_set_server: "utf8"
mariadb_collation_server: "utf8_general_ci"

Examples

- hosts: somehost
  roles:
    - role: supertarto.mariadb

  vars:
    mariadb_use_dump_script: true

    mariadb_databases:
      - name: database1
        collation: utf8_general_ci
        encoding: utf8

    mariadb_users: []
      - name: username
        host: localhost
        password: sqlpassword
        priv: "database1.*:SELECT,UPDATE"

      - name: "{{ mariadb_dump_user }}"
        host: localhost
        password: "{{ mariadb_dump_pass }}"
        priv: "*.*:SELECT,LOCK TABLES"   
 
    mariadb_dump_user: "dumpuser"
    mariadb_dump_pass: "Dumppassword"

Installation

To install, run:

ansible-galaxy install supertarto.mariadb

License

GPL V3.0

Informazioni sul progetto

Install and configure MariaDB with Ansible

Installa
ansible-galaxy install supertarto.mariadb
Licenza
gpl-3.0
Download
1.1k
Proprietario