Skip to content

Commit b8ee93b

Browse files
committed
Merge branch 'master' of git://github.com/dsglaser/ansible-role-mysql into dglaser-master
2 parents 63064ea + 1e75c2f commit b8ee93b

File tree

5 files changed

+42
-15
lines changed

5 files changed

+42
-15
lines changed

README.md

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -97,25 +97,13 @@ 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
103-
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
116102

117103
#### Ubuntu 14.04 MariaDB configuration
118104

105+
On Ubuntu, the package names are named differently, so the `mysql_package` variabl needs to be altered
106+
119107
Set the following variables (at a minimum):
120108

121109
mysql_packages:

tasks/configure.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,19 @@
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+
44+
- name: Set selinux context on datadir
45+
file:
46+
path: "{{ mysql_datadir }}"
47+
setype: mysqld_db_t
48+
3649
- name: Set ownership on slow query log file (if configured).
3750
file:
3851
path: "{{ mysql_slow_query_log_file }}"

tasks/main.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22
# Include variables and define needed variables.
33
- name: Include OS-specific variables.
44
include_vars: "{{ ansible_os_family }}.yml"
5+
when: ansible_os_family != "RedHat"
6+
7+
# Include RedHat 6 variables (mysql)
8+
- name: Include OS-specific variables.
9+
include_vars: "{{ ansible_os_family }}-{{ ansible_lsb.major_release }}.yml"
10+
when: ansible_lsb.major_release < "7"
11+
12+
# Include RedHat 7 variables (mariadb)
13+
- name: Include OS-specific variables.
14+
include_vars: "{{ ansible_os_family }}-{{ ansible_lsb.major_release }}.yml"
15+
when: ansible_os_family >= "7"
516

617
- name: Define mysql_packages.
718
set_fact:
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)