An Ansible role for installing and configuring a MySQL (MariaDB) server.
This role can most likely be used on any Debian-derived distro.
Clone this git repo into your Ansible's role directory, e.g.:
git clone ansible-mysqlserver.git roles/mysqlserver
This role performs the following actions:
- Installs the MySQL (MariaDB) server software
- Installs 'automysqlbackup' (default config performs nightly backups of all DBs)
- Installs 'python-mysqldb' (allows Ansible to perform tasks on the MySQL server, such as creating databases)
Variables to define to use this role:
- mysqlserver_root_password : MySQL root user's clear-text password (will be set)
See defaults/main.yml for the list of variables that can be defined
Variables to define for tasks/configure-autologin-mycnf.yml:
- mysqlcli_user : The OS-user for which to configure my.cnf
- mysqlserver_mycnf_user : The DB-user for auto-login
- mysqlserver_mycnf_password : The DB-user's clear-text password for auto-login
NOTE: The below task is provided for convenience, use with discretion.
This role provides an optional task (setup-app-db.yml) that can be used to bootstrap a database, user, and privileges - as required by *most* types of webapps.
Variables to define:
- db_name : The name of the database to create
- db_username : The username of the user to create for the above database instance
- db_password : The clear-text password of the above user
To use the task, create a play for each database/user/privilege combo you require, e.g.:
- name: Database for ExampleCMS for MyWebsite
- include: roles/mysqlserver/tasks/setup-app-db.yml