From 01abbcaca324fbaf2c858aaa9ccae81fd3265157 Mon Sep 17 00:00:00 2001 From: David Glaser Date: Wed, 6 Apr 2016 09:34:28 -0400 Subject: [PATCH 1/8] Adapted for RHEL 7: Separated RedHat.yml files into RedHat 6 and RedHat 7 files Adapted main.yml to point to the correct file --- tasks/main.yml | 11 +++++++++++ vars/{RedHat.yml => RedHat-6.yml} | 0 vars/RedHat-7.yml | 15 +++++++++++++++ 3 files changed, 26 insertions(+) rename vars/{RedHat.yml => RedHat-6.yml} (100%) create mode 100644 vars/RedHat-7.yml diff --git a/tasks/main.yml b/tasks/main.yml index cc33cb3..beb6cc6 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -2,6 +2,17 @@ # Include variables and define needed variables. - name: Include OS-specific variables. include_vars: "{{ ansible_os_family }}.yml" + when: ansible_os_family != "RedHat" + +# Include RedHat 6 variables (mysql) +- name: Include OS-specific variables. + include_vars: "{{ ansible_os_family }}-{{ ansible_lsb.major_release }}.yml" + when: ansible_lsb.major_release < "7" + +# Include RedHat 7 variables (mariadb) +- name: Include OS-specific variables. + include_vars: "{{ ansible_os_family }}-{{ ansible_lsb.major_release }}.yml" + when: ansible_os_family >= "7" - name: Define mysql_packages. set_fact: diff --git a/vars/RedHat.yml b/vars/RedHat-6.yml similarity index 100% rename from vars/RedHat.yml rename to vars/RedHat-6.yml diff --git a/vars/RedHat-7.yml b/vars/RedHat-7.yml new file mode 100644 index 0000000..0cf3922 --- /dev/null +++ b/vars/RedHat-7.yml @@ -0,0 +1,15 @@ +--- +__mysql_daemon: mariadb +__mysql_packages: + - mariadb + - mariadb-server + - mariadb-libs + - MySQL-python + - perl-DBD-MySQL +__mysql_slow_query_log_file: /var/log/mysql-slow.log +mysql_log_error: /var/log/mariadb/mariadb.log +mysql_syslog_tag: mariadb +mysql_pid_file: /var/run/mariadb/mariadb.pid +mysql_config_file: /etc/my.cnf +mysql_config_include_dir: /etc/my.cnf.d +mysql_socket: /var/lib/mysql/mysql.sock From 64a7b7357a94f061df54bee6346b060d09c7ed99 Mon Sep 17 00:00:00 2001 From: David Glaser Date: Wed, 6 Apr 2016 09:38:18 -0400 Subject: [PATCH 2/8] Updated README for RHEL 7 --- README.md | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 1ae338a..838ae8f 100644 --- a/README.md +++ b/README.md @@ -97,25 +97,13 @@ Replication settings. Set `mysql_server_id` and `mysql_replication_role` by serv ### MariaDB usage -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. +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. -#### RHEL/CentOS 7 MariaDB configuration - -Set the following variables (at a minimum): - - mysql_packages: - - mariadb - - mariadb-server - - mariadb-libs - - MySQL-python - - perl-DBD-MySQL - mysql_daemon: mariadb - mysql_log_error: /var/log/mariadb/mariadb.log - mysql_syslog_tag: mariadb - mysql_pid_file: /var/run/mariadb/mariadb.pid #### Ubuntu 14.04 MariaDB configuration +On Ubuntu, the package names are named differently, so the `mysql_package` variabl needs to be altered + Set the following variables (at a minimum): mysql_packages: From 1e75c2f3e3274ba8b457a1eda90dfaec109cc723 Mon Sep 17 00:00:00 2001 From: David Glaser Date: Wed, 6 Apr 2016 10:45:04 -0400 Subject: [PATCH 3/8] Verify that datadir has been created and selinux context set. Currently selinux context set separately because I'm not sure that Ubuntu has it installed in all cases. --- tasks/configure.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tasks/configure.yml b/tasks/configure.yml index 65ebcc1..ad5ec4c 100644 --- a/tasks/configure.yml +++ b/tasks/configure.yml @@ -33,6 +33,19 @@ file: "path={{ mysql_slow_query_log_file }} state=touch" when: mysql_slow_query_log_enabled +- name: Create datadir if it does not exist + file: + path: "{{ mysql_datadir }}" + state: directory + owner: mysql + group: mysql + mode: 0755 + +- name: Set selinux context on datadir + file: + path: "{{ mysql_datadir }}" + setype: mysqld_db_t + - name: Set ownership on slow query log file (if configured). file: path: "{{ mysql_slow_query_log_file }}" From a7cdfefb55a95ee621232242ef9ac3a961c5c7d6 Mon Sep 17 00:00:00 2001 From: Jeff Geerling Date: Fri, 29 Apr 2016 13:44:59 -0400 Subject: [PATCH 4/8] Fix problems with new CentOS 7 MariaDB fixes. --- README.md | 7 ++----- tasks/configure.yml | 4 ---- tasks/main.yml | 13 ++++--------- 3 files changed, 6 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 838ae8f..fc061a2 100644 --- a/README.md +++ b/README.md @@ -99,12 +99,9 @@ Replication settings. Set `mysql_server_id` and `mysql_replication_role` by serv 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. +#### Ubuntu 14.04 and 16.04 MariaDB configuration -#### Ubuntu 14.04 MariaDB configuration - -On Ubuntu, the package names are named differently, so the `mysql_package` variabl needs to be altered - -Set the following variables (at a minimum): +On Ubuntu, the package names are named differently, so the `mysql_package` variable needs to be altered. Set the following variables (at a minimum): mysql_packages: - mariadb-client diff --git a/tasks/configure.yml b/tasks/configure.yml index fdcf098..d8a4585 100644 --- a/tasks/configure.yml +++ b/tasks/configure.yml @@ -40,10 +40,6 @@ owner: mysql group: mysql mode: 0755 - -- name: Set selinux context on datadir - file: - path: "{{ mysql_datadir }}" setype: mysqld_db_t - name: Set ownership on slow query log file (if configured). diff --git a/tasks/main.yml b/tasks/main.yml index beb6cc6..7e6a137 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -2,17 +2,12 @@ # Include variables and define needed variables. - name: Include OS-specific variables. include_vars: "{{ ansible_os_family }}.yml" - when: ansible_os_family != "RedHat" + when: ansible_os_family != "RedHat" -# Include RedHat 6 variables (mysql) -- name: Include OS-specific variables. - include_vars: "{{ ansible_os_family }}-{{ ansible_lsb.major_release }}.yml" - when: ansible_lsb.major_release < "7" - -# Include RedHat 7 variables (mariadb) -- name: Include OS-specific variables. +# Include version-specific variables for RedHat. +- name: Include OS-specific variables (RedHat). include_vars: "{{ ansible_os_family }}-{{ ansible_lsb.major_release }}.yml" - when: ansible_os_family >= "7" + when: ansible_os_family == "RedHat" - name: Define mysql_packages. set_fact: From 72d6da3922b4feb46917f9d59734a2010391ea4d Mon Sep 17 00:00:00 2001 From: Jeff Geerling Date: Fri, 29 Apr 2016 13:54:15 -0400 Subject: [PATCH 5/8] Another attempt to get tests passing for RHEL. --- tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/main.yml b/tasks/main.yml index 7e6a137..3068053 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -6,7 +6,7 @@ # Include version-specific variables for RedHat. - name: Include OS-specific variables (RedHat). - include_vars: "{{ ansible_os_family }}-{{ ansible_lsb.major_release }}.yml" + include_vars: "{{ ansible_os_family }}-{{ ansible_distribution_version|slice(1) }}.yml" when: ansible_os_family == "RedHat" - name: Define mysql_packages. From 71d6a0b328f5478cbe8f18f1c2ef61ce20a9a922 Mon Sep 17 00:00:00 2001 From: Jeff Geerling Date: Fri, 29 Apr 2016 14:41:29 -0400 Subject: [PATCH 6/8] Fix test build for CentOS 7. --- tasks/main.yml | 2 +- tests/Dockerfile.centos-7 | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/tasks/main.yml b/tasks/main.yml index 3068053..7e6a137 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -6,7 +6,7 @@ # Include version-specific variables for RedHat. - name: Include OS-specific variables (RedHat). - include_vars: "{{ ansible_os_family }}-{{ ansible_distribution_version|slice(1) }}.yml" + include_vars: "{{ ansible_os_family }}-{{ ansible_lsb.major_release }}.yml" when: ansible_os_family == "RedHat" - name: Define mysql_packages. diff --git a/tests/Dockerfile.centos-7 b/tests/Dockerfile.centos-7 index 8aa0654..fb37a6f 100644 --- a/tests/Dockerfile.centos-7 +++ b/tests/Dockerfile.centos-7 @@ -12,6 +12,8 @@ rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \ rm -f /lib/systemd/system/basic.target.wants/*; \ rm -f /lib/systemd/system/anaconda.target.wants/*; +RUN yum -y install redhat-lsb-core + # Install Ansible RUN yum -y install epel-release RUN yum -y install git ansible sudo From 91c3b9c3eb4a2829c8c83815e0809ca6acbc25cd Mon Sep 17 00:00:00 2001 From: Jeff Geerling Date: Fri, 29 Apr 2016 15:36:39 -0400 Subject: [PATCH 7/8] Ensure redhat-lsb-core is installed. --- tasks/main.yml | 6 ++++-- tests/Dockerfile.centos-7 | 2 -- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index 7e6a137..f99dd38 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,10 +1,12 @@ --- -# Include variables and define needed variables. - name: Include OS-specific variables. include_vars: "{{ ansible_os_family }}.yml" when: ansible_os_family != "RedHat" -# Include version-specific variables for RedHat. +- name: Ensure required dependency is installed (RedHat). + yum: name=redhat-lsb-core state=installed + when: ansible_os_family == "RedHat" + - name: Include OS-specific variables (RedHat). include_vars: "{{ ansible_os_family }}-{{ ansible_lsb.major_release }}.yml" when: ansible_os_family == "RedHat" diff --git a/tests/Dockerfile.centos-7 b/tests/Dockerfile.centos-7 index fb37a6f..8aa0654 100644 --- a/tests/Dockerfile.centos-7 +++ b/tests/Dockerfile.centos-7 @@ -12,8 +12,6 @@ rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \ rm -f /lib/systemd/system/basic.target.wants/*; \ rm -f /lib/systemd/system/anaconda.target.wants/*; -RUN yum -y install redhat-lsb-core - # Install Ansible RUN yum -y install epel-release RUN yum -y install git ansible sudo From 3acd799991b6c10e15f2ea32b80ad2335f62270a Mon Sep 17 00:00:00 2001 From: Jeff Geerling Date: Fri, 29 Apr 2016 15:42:47 -0400 Subject: [PATCH 8/8] Install redhat-lsb-core prior to test. --- tasks/main.yml | 5 +---- tests/Dockerfile.centos-6 | 2 ++ tests/Dockerfile.centos-7 | 2 ++ 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index f99dd38..ee2aa4f 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,12 +1,9 @@ --- +# Variable configuration. - name: Include OS-specific variables. include_vars: "{{ ansible_os_family }}.yml" when: ansible_os_family != "RedHat" -- name: Ensure required dependency is installed (RedHat). - yum: name=redhat-lsb-core state=installed - when: ansible_os_family == "RedHat" - - name: Include OS-specific variables (RedHat). include_vars: "{{ ansible_os_family }}-{{ ansible_lsb.major_release }}.yml" when: ansible_os_family == "RedHat" diff --git a/tests/Dockerfile.centos-6 b/tests/Dockerfile.centos-6 index 4a4e7b8..27ff215 100644 --- a/tests/Dockerfile.centos-6 +++ b/tests/Dockerfile.centos-6 @@ -1,5 +1,7 @@ FROM centos:6 +RUN yum -y install redhat-lsb-core + # Install Ansible RUN yum -y update; yum clean all; RUN yum -y install epel-release diff --git a/tests/Dockerfile.centos-7 b/tests/Dockerfile.centos-7 index 8aa0654..fb37a6f 100644 --- a/tests/Dockerfile.centos-7 +++ b/tests/Dockerfile.centos-7 @@ -12,6 +12,8 @@ rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \ rm -f /lib/systemd/system/basic.target.wants/*; \ rm -f /lib/systemd/system/anaconda.target.wants/*; +RUN yum -y install redhat-lsb-core + # Install Ansible RUN yum -y install epel-release RUN yum -y install git ansible sudo