{"id":27088952,"url":"https://github.com/devops-works/ansible-mariadb","last_synced_at":"2026-02-17T06:32:59.623Z","repository":{"id":98718257,"uuid":"399111771","full_name":"devops-works/ansible-mariadb","owner":"devops-works","description":"Basic mariadb role","archived":false,"fork":false,"pushed_at":"2025-01-22T08:52:04.000Z","size":115,"stargazers_count":2,"open_issues_count":1,"forks_count":1,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-01-22T09:34:03.546Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Jinja","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devops-works.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2021-08-23T13:21:03.000Z","updated_at":"2025-01-22T08:51:51.000Z","dependencies_parsed_at":"2024-07-10T09:16:01.816Z","dependency_job_id":"e18c8157-040c-403c-b4da-503edc3952c2","html_url":"https://github.com/devops-works/ansible-mariadb","commit_stats":null,"previous_names":[],"tags_count":62,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devops-works%2Fansible-mariadb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devops-works%2Fansible-mariadb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devops-works%2Fansible-mariadb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devops-works%2Fansible-mariadb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devops-works","download_url":"https://codeload.github.com/devops-works/ansible-mariadb/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247445686,"owners_count":20939953,"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":[],"created_at":"2025-04-06T06:36:44.019Z","updated_at":"2026-02-17T06:32:59.597Z","avatar_url":"https://github.com/devops-works.png","language":"Jinja","readme":"# mariadb server role\n\nmariadb database server role\n\nThis role supports can install standalone server or replication topologies.\n\nIt comes with batteries included:\n\n- Hourly backup integration with ansible-backupninja role (https://github.com/devops-works/ansible-backupninja)\n- (optional) filtering support (via [leucos.ferm](https://github.com/leucos/ansible-ferm))\n\n## Requirements\n\nMySQLdb python package (required by `mysql_*` Ansible modules)\n\n## Role Variables\n\n### Backup\n\nDefine `mariadb_backup_*` variables if you want to create database backups.\nIt will install a backupscript in `/etc/backup.d/hourly`.\n\n- `mariadb_backup` (default: false): whether to run database backups\n- `mariadb_backup_exclude` (default: \"\"): `grep` exclude pattern for databases\n- `mariadb_backup_keep` (default: 30): how many backups do we keep locally\n- `mariadb_backup_s3bucket` (default: \"\"): S3 bucket to export backups to\n- `mariadb_backup_gcloudbucket` (default: \"\"): GCS bucket to export backups to\n- `mariadb_backup_destination` (default: \"/var/backups/mysql/\"): path to store\n  local backups in\n- `mariadb_backup_cron_time` (default: \"15 */2 * * 0-7\"): cron entry for\n  backups\n- `mariadb_backup_gpg_keys_urls` (default: []): list of gpg keys URLS to\n  encrypt backups for\n\n### MySQL config related variables\n\n#### Special vars\n\nThe required version is set in `mariadb_version`. The default is \"5.6\"; The only\nother supported version is \"5.5\".\n\nIf defined, `mariadb_bind_interface` takes precedence over\n`mariadb_bind_address`. Note that `mariadb_bind_interface` *must* be defined for\nmaster replica setup to work.\n\n#### my.cnf vars\n\nAll variables below are their MySQL equivalent.\n\n- `mariadb_bind_address` (default: \"127.0.0.1\")\n- `mariadb_character_set_server` (default: none)\n- `mariadb_collation_server` (default: none)\n- `mariadb_key_buffer` (default: \"16M\"; if set to \"auto\", will be set to 20% of\n  total RAM)\n- `mariadb_master_host` (default: undefined)\n- `mariadb_max_binlog_size` (default: 100M)\n- `mariadb_max_connections` (default: 151)\n- `mariadb_max_heap_table_size` (default: 16777216)\n- `mariadb_open_files_limit` (default: 2565)\n- `mariadb_port` (default: 3306)\n- `mariadb_query_cache_limit` (default: 1M)\n- `mariadb_query_cache_size` (default: 16M)\n- `mariadb_query_cache_strip_comments` (default: 0)\n- `mariadb_query_cache_type` (default: 0)\n- `mariadb_server_id` (default: none)\n- `mariadb_sql_mode` (default: none)\n- `mariadb_thread_cache_size` (default: 8)\n- `mariadb_tmp_dir` (default: /tmp)\n- `mariadb_tmp_table_size` (default: 16777216)\n\n#### Custom vars\n\nIf you want to use variables that are not supported by the template, you can\nfill `mariadb_custom` with whatever variable is needed under it's section.\n\nFor instance:\n\n```yaml\nmariadb_custom:\n  mysqld:\n    slave_skip_errors: 1062\n  mysql:\n    default-character-set: utf8mb4\n```\n\nwould configure mysqld to skip error \"1062\" when replicating, and also set the\ndefault character set for mysql clients.\n\n### Skip daemon restart\n\nIn some situations, you might want to deploy a configuration change without\nrestarting the server to avoid disruptions. For instance, you change the\nvariable manually using `SET GLOBAL` and just want to align the configuration\nwithout restarting.\n\nIn this case, you can execute the playbook with the variable\n`mariadb_skip_restart` set to `true`. This way, the restart handler will be\nskipped.\n\n### Users\n\n`mariadb_users` contains a userlist like so:\n\n```yaml\n  mariadb_users:\n    - name: foo,\n      password: \"bar\",\n      priv: \"*.*:ALL\"\n      host: \"somehost\"\n```\n\nA replication user can be setup with `mariadb_replication_user` and\n`mariadb_replication_password` (default for both is false, which means no\nreplication user).\n\nRoot's password can be set in `mariadb_root_password` (default: none,\n*mandatory*)\n\n### Replication\n\nIf replicas can act as masters for other replicas, `mariadb_replicas_as_masters`\nshould be set to true (default: false). \n\nAlso, for replication to be set-up, `mariadb_replicas_group` should point to an\ninventory group (default: false).\n\n### Firewalling\n\nIf you want to deploy ferm rules, `mariadb_ferm_enabled` should be set to true\n(default: ferm_enabled | default(false)). If you want to deploy nftables rules for the [ansible-nftables](https://github.com/devops-works/ansible-nftables) role, `mariadb_nftables_enabled` should be set to true\n(default: false). Variable\n`mariadb_filter_allow_mariadb_port` is a list that accepts inventory host\nnames, group names or ip ranges. By default, it is empty (`[]`) which means mysql\nport will be filtered to all hosts.\n\nIn order to set-up proper [ferm](https://galaxy.ansible.com/detail#/role/6120)\nrules, replicas network interface must be the same across all replicas, and should\nbe named in `mariadb_replicas_interface` (default: \"{{ mariadb_bind_interface\n}}\"). If it is not set, the role will use `mariadb_bind_interface`.\n\n### Monitoring support\n\nIf both `mariadb_monitoring_user` and `mariadb_monitoring_password` are\ndefined, a mysql user will be created for monitoring.\n\n- `mariadb_monitoring_user`: MySQL user for monitoring integration (default: `false`)\n- `mariadb_monitoring_password`: MySQL user for monitoring integration (default: `false`)\n\nUsage\n-----\n\nThe role is supposed to be used this way from a playbook (\"www\", \"dbreplicas\"\nand \"dbmaster\" are some groups/hosts defined in Ansible inventory):\n\n```yaml\n- hosts: database\n  roles:\n    - role: leucos.mariadb\n      mariadb_filter_allow_mariadb_port: [ \"www\" ]\n      mariadb_replicas_group: dbreplicas\n      mariadb_master_host: dbmaster\n      mariadb_replication_user: replicator\n      mariadb_replication_password: 0mgpass\n      mariadb_root_password: fafdda28e3f\n```\n\nOf course, all the variables could be in a group_vars file (best practice, but\nit is shorter to present it this way, and it can be used to create various\nreplication topologies).\n\nExample master host vars:\n\n```yaml\nmariadb_server_id: 1\n```\n\nExample replica host vars:\n\n```yaml\nmariadb_backup:\n  keep: 360\n  s3bucket: my-awesome-bucker\n  destination: /var/backups/mysql/\n  cron_time: \"15 * * * 0-7\"\n\nmariadb_bind_interface: em2\nmariadb_server_id: 2\n```\n\n# Dependencies\n\nNone\n\n# Warning\n\nTry this role many times and ensure it fits your needs before using it for\nproduction...\n\nWhile this role can help setting up master-replica replication or NEW servers,\nit won't help you setup replication for already deployed servers.\n\n# License\n\nMIT\n\n# Author Information\n\n[@devops-works](https://github.com/devops-works)\n\nPatches welcome!\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevops-works%2Fansible-mariadb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevops-works%2Fansible-mariadb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevops-works%2Fansible-mariadb/lists"}