Code Monkey home page Code Monkey logo

ansible-mariadb's Introduction

Ansible Role: mariadb

Installs and configure a mariadb on varoius linux systems.

Implement also an monitoring user with own table.

GitHub Workflow Status GitHub issues GitHub release (latest by date) Ansible Quality Score

Requirements & Dependencies

Ansible Collections

ansible-galaxy collection install bodsch.core

or

ansible-galaxy collection install --requirements-file collections.yml

tested operating systems

  • ArchLinux
  • Debian based
    • Debian 11 / 12
    • Ubuntu 22.04

RedHat-based systems are no longer officially supported! May work, but does not have to.

usage

use and create own data directory

mariadb_datadir: /var/lib/mysql

create databases

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

create users

mariadb_users:
  - name: example
    password: secret
    encrypted: false
    host: 127.0.0.1
    priv: *.*:USAGE

monitoring

mariadb_monitoring:
  enabled: true
  system_user: "nobody"
  username: 'monitoring'
  password: '8WOMmRWWYHPR'

replication

Enables and configures replication between 2 or more mariadb instances.

mariadb_replication:
  enabled: false
  role: '' # primary or replica
  primary: ''
  # Same keys as `mariadb_users` above.
  user:
    name: replication
    # The password must not be longer than 32 characters!
    # password: ""
    encrypted: false

ATTENTION: The password for replication must not be longer than 32 characters!

see

The following table shows the maximum permissible length for the string-valued options.

Option Maximum Length
MASTER_PASSWORD 32

For example:

mariadb_replication:
  enabled: true
  role: 'primary'
  primary: 'primary.mariadb.internal'
  user:
    name: replication
    password: "vkxHlCVMHAEtEFkEB9pspPB3N"
    encrypted: false

EVERY replica should have a mariadb_server_id greater then 1.

mariadb_server_id: 2

mysql tuner

mariadb_mysqltuner: true

default variables

see default/main.yml:

mariadb_use_external_repo: false
mariadb_version: 10.4

mariadb_debian_repo: "http://mirror.netcologne.de/mariadb/repo"

mariadb_monitoring:
  enabled: true
  system_user: "nobody"
  username: 'monitoring'
  password: '8WOMmRWWYHPR'

mariadb_mysqltuner: true

# The default root user installed by mysql - almost always root
mariadb_root_home: /root
mariadb_root_username: root
mariadb_root_password: root

# Set this to `true` to forcibly update the root password.
mariadb_root_password_update: true
mariadb_user_password_update: false

mariadb_enabled_on_startup: true

# config settings
# every ini part like [mysqld, galera, embedded, ...] becomes an own segment
# for default configuration settings, see: vars/main.yml

# this is read by the standalone daemon and embedded servers
mariadb_config_server: {}

# This group is read by the client library
mariadb_config_client: {}

# These groups are read by MariaDB command-line tools
mariadb_config_mysql: {}

# this is only for the mysqld standalone daemon
mariadb_config_mysqld:
  socket: "{{ mariadb_socket }}"
  skip-external-locking:
  # Skip reverse DNS lookup of clients
  skip-name-resolve: 1
  # enable performance schema
  performance_schema: 1

# NOTE: This file is read only by the traditional SysV init script, not systemd.
mariadb_config_mysqld_safe: {}

mariadb_config_mysqldump: {}

mariadb_config_galera: {}

# this is only for embedded server
mariadb_config_embedded: {}

mariadb_config_custom:
  # This group is only read by MariaDB servers, not by MySQL.
  mariadb: {}
  # This group is only read by MariaDB-$VERSION servers.
  #mariadb-10.1: {}
  #mariadb-10.5: {}
  # This group is *never* read by mysql client library
  client-mariadb: {}
  mysql_upgrade: {}
  mysqladmin: {}
  mysqlbinlog: {}
  mysqlcheck: {}
  mysqlimport: {}
  mysqlshow: {}
  mysqlslap: {}

mariadb_configure_swappiness: true
mariadb_swappiness: 0

# Databases.
mariadb_databases: []

# Users.
mariadb_users: []

# Replication settings (replication is only enabled if master/user have values).
mariadb_server_id: "1"

mariadb_replication:
  # enable / disable replication
  enabled: false
  # 'master' or 'replica'
  role: ''
  # hostname or IP for the master node
  primary: ''
  # Same keys as `mariadb_users` above.
  user: []

Tests

Tests can be performed with molecule and tox. tox supports here with a test matrix, so that different Ansible versions can be used.

see also Actions

tox -e py39-ansible210 -- molecule test

Contribution

Please read Contribution

Development, Branches (Git Tags)

The master Branch is my Working Horse includes the "latest, hot shit" and can be complete broken!

If you want to use something stable, please use a Tagged Version!

Author

  • Bodo Schulz

License

Apache

FREE SOFTWARE, HELL YEAH!

ansible-mariadb's People

Contributors

bodsch avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

davidmorp

ansible-mariadb's Issues

PyMySQL needs Python 3, but 2 is being selected

The mariadb secure-installation fails at the "remove mariadb test database" task.

TASK [remove mariadb test database] ***************************************************************************
Wednesday 14 April 2021  17:20:58 +0200 (0:00:00.018)       0:01:44.065 ******* 
fatal: [database.icinga.local]: FAILED! => changed=false 
  msg: The PyMySQL (Python 2.7 and Python 3.X) or MySQL-python (Python 2.X) module is required.

This was resolved by changing the beginning of ansible-mariadb/tasks/preparations.yml to set the interpreter to python3

- block:
    - name: ensure the ansible_python_interpreter is set to python3 #changed to python 3
      set_fact:
        ansible_python_interpreter: python3 #changed to python 3
    - name: do facts module to get latest information
      setup:
  # Always...
  # when: (
  #   ansible_os_family | lower == 'redhat' and
  #   ansible_distribution_version | int < 8)

I am using Debian 10.
I would make a pull request but I'm not sure if this is the best place to set the interpreter, so i preferred to open an issue.

since version 10.x the regex in package_version is broken

broken version detection

TASK [mariadb : mariadb version] ****************************************************************************************************************************************
Dienstag 02 August 2022  15:12:54 +0200 (0:00:00.067)       0:00:10.465 ******* 
ok: [blackbox.matrix.lan] => 
  msg:
  - 'mariadb version: 0.8 - 0.8'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.