Skip to content

Commit f94f3a6

Browse files
committed
Merge pull request geerlingguy#116 from geerlingguy/dglaser-master
Support MariaDB in RHEL 7 out of the box
2 parents 63064ea + 3acd799 commit f94f3a6

File tree

7 files changed

+37
-19
lines changed

7 files changed

+37
-19
lines changed

README.md

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -97,26 +97,11 @@ Replication settings. Set `mysql_server_id` and `mysql_replication_role` by serv
9797

9898
### MariaDB usage
9999

100-
This role works with either MySQL or a compatible version of MariaDB. On RHEL/CentOS 7+, the mariadb database engine was substituted as the default MySQL replacement package, so you should override the `mysql_packages` variable with the below configuration to make sure MariaDB is installed correctly.
100+
This role works with either MySQL or a compatible version of MariaDB. On RHEL/CentOS 7+, the mariadb database engine was substituted as the default MySQL replacement package. No modifications are necessary though all of the variables still reference 'mysql' instead of mariadb.
101101

102-
#### RHEL/CentOS 7 MariaDB configuration
102+
#### Ubuntu 14.04 and 16.04 MariaDB configuration
103103

104-
Set the following variables (at a minimum):
105-
106-
mysql_packages:
107-
- mariadb
108-
- mariadb-server
109-
- mariadb-libs
110-
- MySQL-python
111-
- perl-DBD-MySQL
112-
mysql_daemon: mariadb
113-
mysql_log_error: /var/log/mariadb/mariadb.log
114-
mysql_syslog_tag: mariadb
115-
mysql_pid_file: /var/run/mariadb/mariadb.pid
116-
117-
#### Ubuntu 14.04 MariaDB configuration
118-
119-
Set the following variables (at a minimum):
104+
On Ubuntu, the package names are named differently, so the `mysql_package` variable needs to be altered. Set the following variables (at a minimum):
120105

121106
mysql_packages:
122107
- mariadb-client

tasks/configure.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@
3333
shell: "touch {{ mysql_slow_query_log_file }} creates={{ mysql_slow_query_log_file }}"
3434
when: mysql_slow_query_log_enabled
3535

36+
- name: Create datadir if it does not exist
37+
file:
38+
path: "{{ mysql_datadir }}"
39+
state: directory
40+
owner: mysql
41+
group: mysql
42+
mode: 0755
43+
setype: mysqld_db_t
44+
3645
- name: Set ownership on slow query log file (if configured).
3746
file:
3847
path: "{{ mysql_slow_query_log_file }}"

tasks/main.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
---
2-
# Include variables and define needed variables.
2+
# Variable configuration.
33
- name: Include OS-specific variables.
44
include_vars: "{{ ansible_os_family }}.yml"
5+
when: ansible_os_family != "RedHat"
6+
7+
- name: Include OS-specific variables (RedHat).
8+
include_vars: "{{ ansible_os_family }}-{{ ansible_lsb.major_release }}.yml"
9+
when: ansible_os_family == "RedHat"
510

611
- name: Define mysql_packages.
712
set_fact:

tests/Dockerfile.centos-6

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
FROM centos:6
22

3+
RUN yum -y install redhat-lsb-core
4+
35
# Install Ansible
46
RUN yum -y update; yum clean all;
57
RUN yum -y install epel-release

tests/Dockerfile.centos-7

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
1212
rm -f /lib/systemd/system/basic.target.wants/*; \
1313
rm -f /lib/systemd/system/anaconda.target.wants/*;
1414

15+
RUN yum -y install redhat-lsb-core
16+
1517
# Install Ansible
1618
RUN yum -y install epel-release
1719
RUN yum -y install git ansible sudo
File renamed without changes.

vars/RedHat-7.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
__mysql_daemon: mariadb
3+
__mysql_packages:
4+
- mariadb
5+
- mariadb-server
6+
- mariadb-libs
7+
- MySQL-python
8+
- perl-DBD-MySQL
9+
__mysql_slow_query_log_file: /var/log/mysql-slow.log
10+
mysql_log_error: /var/log/mariadb/mariadb.log
11+
mysql_syslog_tag: mariadb
12+
mysql_pid_file: /var/run/mariadb/mariadb.pid
13+
mysql_config_file: /etc/my.cnf
14+
mysql_config_include_dir: /etc/my.cnf.d
15+
mysql_socket: /var/lib/mysql/mysql.sock

0 commit comments

Comments
 (0)