Skip to content

while-true-do/ansible-role-srv_mariadb

Repository files navigation

Github (tag) Github (license) Github (issues) Github (pull requests)

Travis (com)

Ansible (min. version) Ansible (platforms) Ansible (tags)

Ansible Role: srv_mariadb

An Ansible Role to install and configure mariadb.

Motivation

mariadb is one of the most popular database servers. Made by the original developers of MySQL.

Description

This role installs and configures mariadb.

  • install mariadb packages
  • configure mariadb
  • configure firewalld
  • perform mysql-secure-installation steps

Requirements

Used Modules:

Installation

Install from Ansible Galaxy

ansible-galaxy install while_true_do.srv_mariadb

Install from Github

git clone https://github.com/while-true-do/ansible-role-srv_mariadb.git while_true_do.srv_mariadb

Usage

Role Variables

---
# defaults file for while_true_do.srv_mariadb

# Define the source of installation
# Currently only distribution packages are supported
wtd_srv_mariadb_source: "distribution"

## Package Management
wtd_srv_mariadb_package:
  - mariadb-server
  - python3-mysql
# State can be present|latest|absent
wtd_srv_mariadb_package_state: "present"

## Configuration Management
wtd_srv_mariadb_conf_root_pass: ""

wtd_srv_mariadb_conf_my_path: "/etc/my.cnf"
wtd_srv_mariadb_conf_server_path: "/etc/my.cnf.d/mariadb-server.cnf"

wtd_srv_mariadb_conf_server:
  port: "3306"
  bind_address: "127.0.0.1"
  character_set: "utf8mb4"
  symbolic_links: "0"
  data_dir: "/var/lib/mysql"
  socket: "/var/lib/mysql/mysql.sock"

wtd_srv_mariadb_conf_innodb:
  file_per_table: "true"
  buffer_pool_size: "128M"

wtd_srv_mariadb_conf_query_cache:
  type: "1"
  limit: "256K"
  min_res_unit: "2k"
  cache_size: "64M"

## Service Management
wtd_srv_mariadb_service: "mariadb"
# State can be started|stopped
wtd_srv_mariadb_service_state: "started"
wtd_srv_mariadb_service_enabled: true

## Firewalld Management
wtd_srv_mariadb_fw_mgmt: true
wtd_srv_mariadb_fw_service: "mysql"
# State can be enabled|disabled
wtd_srv_mariadb_fw_state: "enabled"
# Zone can be according to defined zones on your machine.
wtd_srv_mariadb_fw_zone: "public"

## Host Management
wtd_srv_mariadb_reboot_enabled: true
wtd_srv_mariadb_reboot_msg: "System is going down to ..."
wtd_srv_mariadb_reboot_timeout: 3600

Example Playbook

Running Ansible Roles can be done in a playbook.

Simple

---
- hosts: all
  roles:
    - role: while_true_do.srv_mariadb
      wtd_srv_mariadb_conf_root_pass: "myPassword"

Allow network traffic

- hosts: all
  roles:
    - role: while_true_do.srv_mariadb
      wtd_srv_mariadb_conf_root_pass: "myPassword"
      wtd_srv_mariadb_conf_server:
        port: "3306"
        bind_address: "0.0.0.0"

Known Issues

  1. RedHat Testing is currently not possible in public, due to limitations in subscriptions.
  2. Some services and features cannot be tested properly, due to limitations in docker.

Testing

Most of the "generic" tests are located in the Test Library.

Ansible specific testing is done with Molecule.

Infrastructure testing is done with testinfra.

Automated testing is done with Travis CI.

Contribute

Thank you so much for considering to contribute. We are very happy, when somebody is joining the hard work. Please fell free to open Bugs, Feature Requests or Pull Requests after reading the Contribution Guideline.

See who has contributed already in the kudos.txt.

License

This work is licensed under a BSD-3-Clause License.

Contact