/ansible-role-mysql

Install and configure mysql on your system.

Primary LanguageJinjaApache License 2.0Apache-2.0

Install and configure mysql on your system.

GitHub GitLab Quality Downloads Version
github gitlab quality downloads Version

This example is taken from molecule/resources/converge.yml and is tested on each push, pull request and release.

---
- name: Converge
  hosts: all
  become: yes
  gather_facts: yes

  roles:
    - role: robertdebock.mysql
      mysql_databases:
        - name: my_db
          encoding: utf8
          collation: utf8_bin
      mysql_users:
        - name: my_user
          password: my_pass
          priv: "my_db.*:ALL"
          update_password: on_create

The machine needs to be prepared in CI this is done using molecule/resources/prepare.yml:

---
- name: Prepare
  hosts: all
  become: yes
  gather_facts: no

  roles:
    - role: robertdebock.bootstrap

Also see a full explanation and example on how to use these roles.

These variables are set in defaults/main.yml:

---
# defaults file for mysql

# The address mysql should bind to.
mysql_bind_address: 127.0.0.1

# The password to set for the root user. Also stored in my.cnf
mysql_root_password: "s3Cur31t4."

# The buffer pool size.
mysql_innodb_buffer_pool_size: 1G

# The io capacity.
mysql_innodb_io_capacity: 4000

The following roles are used to prepare a system. You may choose to prepare your system in another way, I have tested these roles as well.

Requirement GitHub GitLab
robertdebock.bootstrap Build Status GitHub Build Status GitLab

This role is a part of many compatible roles. Have a look at the documentation of these roles for further information.

Here is an overview of related roles: dependencies

This role has been tested on these container images:

container tags
debian buster
el 8
fedora all
opensuse all
ubuntu focal, bionic

The minimum version of Ansible required is 2.10, tests have been done to:

  • The previous version.
  • The current version.
  • The development version.

Some variarations of the build matrix do not work. These are the variations and reasons why the build won't work:

variation reason
Alpine The PyMySQL (Python 2.7 and Python 3.X) or MySQL-python (Python 2.X) module is required.
amazonlinux:1 /etc/init.d/mysqld: line 16: /etc/sysconfig/network: No such file or directory

If you find issues, please register them in GitHub

Apache-2.0

I'd like to thank everybody that made contributions to this repository. It motivates me, improves the code and is just fun to collaborate.

Robert de Bock

Please consider sponsoring me.