{"id":14969090,"url":"https://github.com/bodsch/ansible-mariadb","last_synced_at":"2025-10-26T06:31:00.679Z","repository":{"id":41974354,"uuid":"226016236","full_name":"bodsch/ansible-mariadb","owner":"bodsch","description":"Installs and configure a mariadb (with TLS and/or Replication or Galera Cluster) on varoius linux systems.","archived":false,"fork":false,"pushed_at":"2025-01-09T09:07:00.000Z","size":320,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-01-31T16:12:40.457Z","etag":null,"topics":["ansible","ansible-role","automation","database","galera-cluster","mariadb-database","mariadb-galera-cluster","mariadb-replication","mariadb-server"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bodsch.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-12-05T04:30:21.000Z","updated_at":"2025-01-09T09:05:29.000Z","dependencies_parsed_at":"2023-02-01T05:15:40.255Z","dependency_job_id":"2ee7960f-2781-40f1-bd65-af1d3bce724c","html_url":"https://github.com/bodsch/ansible-mariadb","commit_stats":{"total_commits":144,"total_committers":3,"mean_commits":48.0,"dds":0.04861111111111116,"last_synced_commit":"0094728f3ce606a10a6d60b6c0fb5aaf2c13bb19"},"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bodsch%2Fansible-mariadb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bodsch%2Fansible-mariadb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bodsch%2Fansible-mariadb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bodsch%2Fansible-mariadb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bodsch","download_url":"https://codeload.github.com/bodsch/ansible-mariadb/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238276061,"owners_count":19445340,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansible","ansible-role","automation","database","galera-cluster","mariadb-database","mariadb-galera-cluster","mariadb-replication","mariadb-server"],"created_at":"2024-09-24T13:41:06.822Z","updated_at":"2025-10-26T06:31:00.673Z","avatar_url":"https://github.com/bodsch.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Ansible Role:  `mariadb`\n\n\nInstalls and configure a mariadb on varoius linux systems.\n\nImplement also an monitoring user with own table.\n\n\u003e This role is currently being migrated to a [collection](https://github.com/bodsch/ansible-collection-database).\n\u003e Please submit issues and pull requests against this collection!\n\n---\n\n[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/bodsch/ansible-mariadb/main.yml?branch=main)][ci]\n[![GitHub issues](https://img.shields.io/github/issues/bodsch/ansible-mariadb)][issues]\n[![GitHub release (latest by date)](https://img.shields.io/github/v/release/bodsch/ansible-mariadb)][releases]\n[![Ansible Downloads](https://img.shields.io/ansible/role/d/bodsch/mariadb?logo=ansible)][galaxy]\n\n[ci]: https://github.com/bodsch/ansible-mariadb/actions\n[issues]: https://github.com/bodsch/ansible-mariadb/issues?q=is%3Aopen+is%3Aissue\n[releases]: https://github.com/bodsch/ansible-mariadb/releases\n[galaxy]: https://galaxy.ansible.com/ui/standalone/roles/bodsch/mariadb/\n\n## Requirements \u0026 Dependencies\n\nAnsible Collections\n\n- [bodsch.core](https://github.com/bodsch/ansible-collection-core)\n\n```bash\nansible-galaxy collection install bodsch.core\n```\nor\n```bash\nansible-galaxy collection install --requirements-file collections.yml\n```\n\n## tested operating systems\n\n* ArchLinux\n* Debian based\n    - Debian 11 / 12\n    - Ubuntu 22.04\n\n\u003e **RedHat-based systems are no longer officially supported! May work, but does not have to.**\n\n## usage\n\n### use and create own data directory\n\n```yaml\nmariadb_datadir: /var/lib/mysql\n```\n\n### create system users\n\nTo create a `.my.cnf` on an instance, `mariadb_system_users` can be used.\n\nIf no password is set, the associated task is skipped.\n\n\n| variable   | description |\n| :---       | :-----      |\n| `username` | The user name for administrative access. |\n| `password` | If no password is set, the associated task is skipped. |\n| `home`     | The home directory under which a `.my.cnf` is created. |\n| `update`   | Should the password be updated. |\n| `ignore`   | If the entire process is to be ignored, `ignore` must be set to `true`. |\n\n```yaml\nmariadb_system_users:\n  - username: root\n    password: \"\"\n    home: /root\n    update: true\n    ignore: true\n```\n\n### create databases\n\n```yaml\nmariadb_databases:\n  - name: example\n    collation: utf8_general_ci\n    encoding: utf8\n```\n\n### create database users\n\n```yaml\nmariadb_users:\n  - name: example\n    password: secret\n    encrypted: false\n    host: 127.0.0.1\n    priv: *.*:USAGE\n```\n\n### monitoring\n\n```yaml\nmariadb_monitoring:\n  enabled: true\n  system_user: \"nobody\"\n  username: 'monitoring'\n  password: '8WOMmRWWYHPR'\n```\n\n### replication\n\nEnables and configures replication between 2 or more mariadb instances.\n\n```yaml\nmariadb_replication:\n  enabled: false\n  role: '' # primary or replica\n  primary: ''\n  # Same keys as `mariadb_users` above.\n  user:\n    name: replication\n    # The password must not be longer than 32 characters!\n    # password: \"\"\n    encrypted: false\n```\n\n**ATTENTION: The password for replication must not be longer than 32 characters!**\n\n[see](https://dev.mysql.com/doc/refman/5.6/en/change-master-to.html)\n\nThe following table shows the maximum permissible length for the string-valued options.\n| Option          | Maximum Length |\n| :----           | :----          |\n| MASTER_PASSWORD | 32             |\n\nFor example:\n\n```yaml\nmariadb_replication:\n  enabled: true\n  role: 'primary'\n  primary: 'primary.mariadb.internal'\n  user:\n    name: replication\n    password: \"vkxHlCVMHAEtEFkEB9pspPB3N\"\n    encrypted: false\n```\n\n**EVERY replica** should have a `mariadb_server_id` greater then `1`.\n\n```yaml\nmariadb_server_id: 2\n```\n\n### galera cluster\n\nWith a gallery cluster, starting the individual instances correctly is extremely important!  \nOne of the instances must be started first as the primary node. All subsequent nodes then replicate the information.  \nA restart of the mariadb service must not destroy the cluster status, so they must be restarted **serially** and **not in parallel**!\n\nExample configuration:\n\n```yaml\nmariadb_galera:\n  node_addresses:\n    - address: \"10.29.0.10\"\n    - address: \"10.29.0.21\"\n    - address: \"10.29.0.22\"\n  sst:\n    method: rsync\n    auth:\n      username: \"sstuser\"\n      password: \"\"\n  node:\n    name: \"{{ ansible_hostname }}\"\n    id: \"{{ mariadb_server_id | default('1') }}\"\n    address: \"{{ ansible_default_ipv4.address | default('127.0.0.1') }}\"\n  gtid_domain_id: \"{{ mariadb_server_id | default('1') }}\"\n\n  provider_options:\n    - debug=yes\n    - gcache.size=512M\n    - gcache.page_size=128M\n    - gcache.recover=yes\n    - gmcast.peer_timeout=PT10S\n    - pc.announce_timeout=PT10S\n\n```\n\n(A fully functional configuration can be found under [molecule/galera-cluster](molecule/galera-cluster).)\n\n\n### mysql tuner\n\n```yaml\nmariadb_mysqltuner: true\n```\n\n\n### default variables\n\nsee [default/main.yml](default/main.yml):\n\n```yaml\nmariadb_use_external_repo: false\nmariadb_version: 10.4\n\nmariadb_debian_repo: \"http://mirror.netcologne.de/mariadb/repo\"\n\nmariadb_monitoring:\n  enabled: false\n  system_user: \"nobody\"\n  username: 'monitoring'\n  password: '8WOMmRWWYHPR'\n\nmariadb_mysqltuner: false\n\nmariadb_system_users:\n  - username: root\n    password: \"\"\n    home: /root\n    update: true\n    ignore: true\n\nmariadb_enabled_on_startup: true\n\n# config settings\n# every ini part like [mysqld, galera, embedded, ...] becomes an own segment\n# for default configuration settings, see: vars/main.yml\n\n# this is read by the standalone daemon and embedded servers\nmariadb_config_server: {}\n\n# This group is read by the client library\nmariadb_config_client: {}\n\n# These groups are read by MariaDB command-line tools\nmariadb_config_mysql: {}\n\n# this is only for the mysqld standalone daemon\nmariadb_config_mysqld:\n  socket: \"{{ mariadb_socket }}\"\n  skip-external-locking:\n  # Skip reverse DNS lookup of clients\n  skip-name-resolve: 1\n  # enable performance schema\n  performance_schema: 1\n\n# NOTE: This file is read only by the traditional SysV init script, not systemd.\nmariadb_config_mysqld_safe: {}\n\nmariadb_config_mysqldump: {}\n\nmariadb_config_galera: {}\n\n# this is only for embedded server\nmariadb_config_embedded: {}\n\nmariadb_config_custom:\n  # This group is only read by MariaDB servers, not by MySQL.\n  mariadb: {}\n  # This group is only read by MariaDB-$VERSION servers.\n  #mariadb-10.1: {}\n  #mariadb-10.5: {}\n  # This group is *never* read by mysql client library\n  client-mariadb: {}\n  mysql_upgrade: {}\n  mysqladmin: {}\n  mysqlbinlog: {}\n  mysqlcheck: {}\n  mysqlimport: {}\n  mysqlshow: {}\n  mysqlslap: {}\n\nmariadb_configure_swappiness: true\nmariadb_swappiness: 0\n\n# Databases.\nmariadb_databases: []\n\n# Users.\nmariadb_users: []\n\n# Replication settings (replication is only enabled if master/user have values).\nmariadb_server_id: \"1\"\n\nmariadb_replication:\n  # enable / disable replication\n  enabled: false\n  # 'master' or 'replica'\n  role: ''\n  # hostname or IP for the master node\n  primary: ''\n  # Same keys as `mariadb_users` above.\n  user: []\n  \nmariadb_galera:\n  node_addresses: []\n  sst:\n    method: rsync\n    auth:\n      username: \"sstuser\"\n      password: \"\"\n  node:\n    name: \"{{ ansible_hostname }}\"\n    id: \"{{ mariadb_server_id | default('1') }}\"\n    address: \"{{ ansible_default_ipv4.address | default('127.0.0.1') }}\"\n  gtid_domain_id: \"{{ mariadb_server_id | default('1') }}\"\n  provider_options: []\n```\n\n## Tests\n\nTests can be performed with `molecule` and `tox`.\n`tox` supports here with a test matrix, so that different Ansible versions can be used.\n\nsee also [Actions](https://github.com/bodsch/ansible-mariadb/actions)\n\n```bash\ntox -e py39-ansible210 -- molecule test\n```\n\n## Contribution\n\nPlease read [Contribution](CONTRIBUTING.md)\n\n## Development,  Branches (Git Tags)\n\nThe `master` Branch is my *Working Horse* includes the \"latest, hot shit\" and can be complete broken!\n\nIf you want to use something stable, please use a [Tagged Version](https://github.com/bodsch/ansible-mariadb/tags)!\n\n## Author\n\n- Bodo Schulz\n\n## License\n\n[Apache](LICENSE)\n\n**FREE SOFTWARE, HELL YEAH!**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbodsch%2Fansible-mariadb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbodsch%2Fansible-mariadb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbodsch%2Fansible-mariadb/lists"}