Ansible role that installs MySQL 5.6 or 5.7 on a RHEL7 host
This role can also configure MySQL databases and users
Please take note of the following assumptions:
- the MySQL server uses Red Hat Enterprise Linux 7 as the OS
- project-specific variables for this role can be defined in a vars file with a name following the format of
projectname_envname.yml
- an example vars file is available in
vars/exampleproj_test.yml
- this vars file will contain sensitive information and should be encrypted with ansible-vault
- NOTE: if you choose not to use the vars file for including the variable definitions, they should be defined in the playbook file
- an example vars file is available in
Variables that need to be defined in the play file or the host inventory file - please note these should match the naming used for the vars file:
project_name
- defines the name of the the project that requires one or more MySQL databases and users - there is no default valueenv_name
- defines the name of the deploy environment (e.g. test, stage, prod) - there is no default valuemysql_install_version
- defines the version of MySQL to use (this role only supports installing 5.6 or 5.7) - default is 5.6
Variables that do need to be defined in the project vars file:
-
mysql_databases
- this is the list of databases to createname
- defines the name of the database to createcollation
- defines the type of collation scheme (default is:utf8_bin
)encoding
- defines the type of text encoding to use (default is:utf8
)
-
mysql_users
- this is the list of users to createname
- defines the usernamehost
- defines the host where the user is allowed to connect frompassword
- defines the password for this userpriv
: - defines the database privileges for this user (syntax should bedbname
.*
:PRIV - e.g.exampledb.*:ALL
)
None.
---
- name: uclalib_mysqltest.yml
become: yes
become_method: sudo
hosts: all
user: ansible
vars:
project_name: exampleproj
env_name: test
roles:
- { role: uclalib_role_rhel7repos }
- { role: uclalib_role_epel }
- { role: uclalib_role_mysql, mysql_install_version: '5.6' }