Ansible role to install and configure a simple MariaDB.
Building and improving this Ansible role have been sponsored by my current and previous employers like Cloudpunks GmbH and Proact Deutschland GmbH.
- Requirements
- Default Variables
- mariadb_backup_addition_script
- mariadb_backup_cron
- mariadb_backup_enabled
- mariadb_backup_formatting
- mariadb_backup_ignore
- mariadb_backup_path
- mariadb_backup_retention
- mariadb_bind_address
- mariadb_cpu_shares
- mariadb_database
- mariadb_default_folders
- mariadb_default_labels
- mariadb_default_publish
- mariadb_default_volumes
- mariadb_exporter_args
- mariadb_exporter_collect_info_schema_tables
- mariadb_exporter_cpu_shares
- mariadb_exporter_default_labels
- mariadb_exporter_default_publish
- mariadb_exporter_download
- mariadb_exporter_enabled
- mariadb_exporter_extra_labels
- mariadb_exporter_extra_publish
- mariadb_exporter_image
- mariadb_exporter_memory_limit
- mariadb_exporter_memory_soft_limit
- mariadb_exporter_memory_swap
- mariadb_exporter_network
- mariadb_exporter_number_of_cpus
- mariadb_exporter_pull_image
- mariadb_exporter_version
- mariadb_extra_configs
- mariadb_extra_databases
- mariadb_extra_folders
- mariadb_extra_labels
- mariadb_extra_publish
- mariadb_extra_users
- mariadb_extra_volumes
- mariadb_galera_address
- mariadb_galera_cluster
- mariadb_galera_enabled
- mariadb_galera_name
- mariadb_galera_nodes
- mariadb_galera_primary
- mariadb_global_databases
- mariadb_global_users
- mariadb_ignore_db_dirs
- mariadb_image
- mariadb_innodb_buffer_pool_instances
- mariadb_innodb_buffer_pool_size
- mariadb_innodb_file_per_table
- mariadb_innodb_flush_log_at_trx_commit
- mariadb_innodb_io_capacity
- mariadb_innodb_max_dirty_pages_pct
- mariadb_installation
- mariadb_key_buffer_size
- mariadb_keyring
- mariadb_limit_number_files
- mariadb_lower_case_table_names
- mariadb_max_allowed_packet
- mariadb_max_connections
- mariadb_memory_limit
- mariadb_memory_soft_limit
- mariadb_memory_swap
- mariadb_network
- mariadb_number_of_cpus
- mariadb_oom_score_adjust
- mariadb_packages
- mariadb_password
- mariadb_pull_image
- mariadb_query_cache_size
- mariadb_query_cache_type
- mariadb_root_hosts
- mariadb_root_password
- mariadb_root_username
- mariadb_skip_name_resolve
- mariadb_symbolic_links
- mariadb_temp_directory
- mariadb_timeout_start_sec
- mariadb_upstream_arch
- mariadb_upstream_mirror
- mariadb_upstream_repo
- mariadb_upstream_version
- mariadb_username
- Discovered Tags
- Dependencies
- License
- Author
- Minimum Ansible version:
2.10
Additional commands at the end of the script
mariadb_backup_addition_script:
A simple cron timing definition like hourly, daily or weekly
mariadb_backup_cron: daily
Enable or disable the backup script
mariadb_backup_enabled: false
Date format for the backup folder name
mariadb_backup_formatting: '%F'
Ignoring this filter via grep on database selection
mariadb_backup_ignore: (_backup|mysql|sys|information_schema|performance_schema)
Path to store the backups
mariadb_backup_path: /var/lib/mysql/_backup
Retention period to keep backups
mariadb_backup_retention: 7
Bind address for the server
mariadb_bind_address: 0.0.0.0
CPU shares with Docker deployment
mariadb_cpu_shares:
mariadb_cpu_shares: '512'
Database used within docker deployment
mariadb_database:
List of default folders to create
mariadb_default_folders:
- /etc/systemd/system/mariadb.service.d
- /etc/mysql
- /etc/mysql/mariadb.conf.d
List of default labels to assign to docker
mariadb_default_labels: []
List of default port publishing for docker
mariadb_default_publish: []
mariadb_default_publish:
- 127.0.0.1:3306:3306
List of default volumes to mount for docker
mariadb_default_volumes:
- /var/lib/mysql:/var/lib/mysql
List of arguments joined for the executable
mariadb_exporter_args: []
Enable info schema tables collector
mariadb_exporter_collect_info_schema_tables: true
CPU shares with Docker deployment
mariadb_exporter_cpu_shares:
mariadb_exporter_cpu_shares: '512'
List of default labels to assign to docker on OAuth2 Proxy
mariadb_exporter_default_labels: []
List of default port publishing for docker on OAuth2 Proxy
mariadb_exporter_default_publish: []
mariadb_exporter_default_publish:
- 127.0.0.1:9104:9104
URL to the archive of the release to install
mariadb_exporter_download: https://github.com/prometheus/mysqld_exporter/releases/download/v{{
mariadb_exporter_version }}/mysqld_exporter-{{ mariadb_exporter_version }}.linux-amd64.tar.gz
Enable the mariadb exporter
mariadb_exporter_enabled: true
List of extra labels to assign to docker on OAuth2 Proxy
mariadb_exporter_extra_labels: []
List of extra port publishing for docker on OAuth2 Proxy
mariadb_exporter_extra_publish: []
mariadb_exporter_extra_publish:
- 127.0.0.1:9104:9104
Docker image to use for deployment on OAuth2 Proxy
mariadb_exporter_image: prom/mysqld-exporter:v{{ mariadb_exporter_version }}
Memory limit with Docker deployment
mariadb_exporter_memory_limit:
mariadb_exporter_memory_limit: 1024m
Soft memory limit with Docker deployment
mariadb_exporter_memory_soft_limit:
mariadb_exporter_memory_soft_limit: 512m
Swap usage with Docker deployment
mariadb_exporter_memory_swap:
mariadb_exporter_memory_swap: 2048m
Optional docker network to attach on OAuth2 Proxy
mariadb_exporter_network: '{{ mariadb_network }}'
Number of CPUs with Docker deployment
mariadb_exporter_number_of_cpus:
mariadb_exporter_number_of_cpus: '1.5'
Pull image as part of the tasks
mariadb_exporter_pull_image: true
Version of the release to install
mariadb_exporter_version: 0.16.0
Write additional config files
mariadb_extra_configs: []
mariadb_extra_configs:
- name: example
priority: 50
content: |
foo1 = bar1
foo2 = bar2
foo3 = bar3
- name: foobar
state: absent
List of additional databases to create for native installation
mariadb_extra_databases: []
mariadb_extra_databases:
- name: example
collation: utf8mb4_general_ci
encoding: utf8mb4
state: present
- name: foobar
state: absent
List of extra folders to create
mariadb_extra_folders: []
mariadb_extra_folders:
- /path/to/host/folder1
- /path/to/host/folder2
- /path/to/host/folder3
List of extra labels to assign to docker
mariadb_extra_labels: []
List of extra port publishing for docker
mariadb_extra_publish: []
mariadb_extra_publish:
- 127.0.0.1:3306:3306
List of additional users to create for native installation
mariadb_extra_users: []
mariadb_extra_users:
- name: example
password: p433w0rd
host: '%'
priv: '*.*:ALL'
state: present
- name: foobar
state: absent
List of extra volumes to mount for docker
mariadb_extra_volumes: []
mariadb_extra_volumes:
- /path/to/host/folder1:/path/within/container1
- /path/to/host/folder2:/path/within/container2
- /path/to/host/folder3:/path/within/container3
Node address within galera cluster
mariadb_galera_address: '{{ ansible_address }}'
mariadb_galera_cluster: galera
Enable galera clustering
mariadb_galera_enabled: false
Node name within galera cluster
mariadb_galera_name: '{{ inventory_hostname }}'
Node addresses part of galera cluster
mariadb_galera_nodes: []
Inventory of primary galera node
mariadb_galera_primary:
List of databases to create for native installation
mariadb_global_databases: []
mariadb_global_databases:
- name: example
collation: utf8mb4_general_ci
encoding: utf8mb4
state: present
- name: foobar
state: absent
List of users to create for native installation
mariadb_global_users: []
mariadb_global_users:
- name: example
password: p433w0rd
host: '%'
priv: '*.*:ALL'
state: present
- name: foobar
state: absent
List of ignored database directories
mariadb_ignore_db_dirs: []
Docker image to use for deployment
mariadb_image: mariadb:{{ mariadb_upstream_version }}
InnoDB buffer pool instances
mariadb_innodb_buffer_pool_instances: 1
InnoDB buffer pool size
mariadb_innodb_buffer_pool_size: 256M
InnoDB file per table
mariadb_innodb_file_per_table: 1
InnoDB flush at trx commit
mariadb_innodb_flush_log_at_trx_commit: 1
InnoDB IO capacity
mariadb_innodb_io_capacity: 1000
InnoDB max dirty pages percentage
mariadb_innodb_max_dirty_pages_pct: 90
Select installation method, could be native or docker
mariadb_installation: native
Key buffer size
mariadb_key_buffer_size: 32M
Path for the repository keyring
mariadb_keyring: /usr/share/keyrings/mariadb-archive-keyring.gpg
Number of allowed open files for systemd service
mariadb_limit_number_files: 32768
Lowercase table names
mariadb_lower_case_table_names: 0
Max allowed packet
mariadb_max_allowed_packet: 64M
Max allowed connections
mariadb_max_connections: 1000
Memory limit with Docker deployment
mariadb_memory_limit:
mariadb_memory_limit: 1024m
Soft memory limit with Docker deployment
mariadb_memory_soft_limit:
mariadb_memory_soft_limit: 512m
Swap usage with Docker deployment
mariadb_memory_swap:
mariadb_memory_swap: 2048m
Optional docker network to attach
mariadb_network:
Number of CPUs with Docker deployment
mariadb_number_of_cpus:
mariadb_number_of_cpus: '1.0'
Adjustment score for OOM killer
mariadb_oom_score_adjust: -999
List of packages to install
mariadb_packages:
- mariadb-server
- mariadb-client
- mariadb-backup
- mycli
- python3-pymysql
- rsync
Password used within docker deployment
mariadb_password:
Pull image as part of the tasks
mariadb_pull_image: true
Query cache size
mariadb_query_cache_size: 0
Query cache type
mariadb_query_cache_type: 0
Allowed hosts for root user
mariadb_root_hosts:
- localhost
- 127.0.0.1
Password for the root user
mariadb_root_password: root
Username for the root user
mariadb_root_username: root
Skip name resolving
mariadb_skip_name_resolve: true
Symbolic links
mariadb_symbolic_links: 0
Temporary directory used by MariaDB
mariadb_temp_directory:
Time to wait for daemon startup
mariadb_timeout_start_sec: 120
Upstream repo architecture
mariadb_upstream_arch: "{{ 'arm64' if ansible_architecture == 'aarch64' else 'amd64'
}}"
Upstream repo mirror URL
mariadb_upstream_mirror: http://mirror.23m.com/mariadb/repo
Install from upstream repository
mariadb_upstream_repo: true
Upstream repo version
mariadb_upstream_version: 11.1
Username used within docker deployment
mariadb_username:
mariadb
mariadb-exporter
Apache-2.0