Add gentoo support to galera_server

Depends-On: https://review.openstack.org/633289
Change-Id: I1ba3630e3f673aab419ebaff966f88868560df3b
This commit is contained in:
Matthew Thode 2019-01-27 00:29:04 -06:00
parent 30bdc809bb
commit ccf108ed24
No known key found for this signature in database
GPG Key ID: 64A37BEAAE19A4E8
9 changed files with 125 additions and 12 deletions

View File

@ -16,7 +16,7 @@
- name: Reload the systemd daemon - name: Reload the systemd daemon
systemd: systemd:
daemon_reload: yes daemon_reload: yes
name: mysql name: "{{ mysql_service_name }}"
enabled: "yes" enabled: "yes"
- name: Check node status - name: Check node status
@ -70,7 +70,7 @@
- name: Restart mysql (All) - name: Restart mysql (All)
service: service:
name: mysql name: "{{ mysql_service_name }}"
state: "{{ (not hostvars[item]['galera_cluster_ready'] | bool) | ternary('started', 'restarted') }}" state: "{{ (not hostvars[item]['galera_cluster_ready'] | bool) | ternary('started', 'restarted') }}"
environment: environment:
MYSQLD_STARTUP_TIMEOUT: 180 MYSQLD_STARTUP_TIMEOUT: 180

View File

@ -0,0 +1,39 @@
---
# Copyright 2019, Matthew Thode
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
- name: Install galera_server role packages
package:
name: "{{ galera_packages_list }}"
state: "{{ galera_server_package_state }}"
newuse: "{{ (ansible_pkg_mgr == 'portage') | ternary('yes', omit) }}"
changed_use: "{{ (ansible_pkg_mgr == 'portage') | ternary('yes', omit) }}"
noreplace: "{{ (ansible_pkg_mgr == 'portage') | ternary('yes', omit) }}"
jobs: "{{ (ansible_pkg_mgr == 'portage') | ternary('4', omit) }}"
register: install_remote_packages
until: install_remote_packages is success
retries: 5
delay: 2
- name: Ensure mysql config directories exists
file:
src: "{{ item.src | default(omit) }}"
path: "{{ item.path }}"
state: "{{ item.state }}"
force: "{{ item.force | default(omit) }}"
with_items:
- path: "/etc/mysql"
state: "directory"
- path: "{{ galera_etc_include_dir }}"
state: "directory"

View File

@ -46,6 +46,7 @@
# as all of these tasks will be run on Package install # as all of these tasks will be run on Package install
# and running them again will cause a conflict within # and running them again will cause a conflict within
# debian based deployments. # debian based deployments.
# NOTE(prometheanfire): Ditto Gentoo ^
- name: Create galera initial secure tool - name: Create galera initial secure tool
template: template:
src: "galera_secure_node.j2" src: "galera_secure_node.j2"
@ -53,6 +54,7 @@
mode: "0750" mode: "0750"
when: when:
- ansible_pkg_mgr != "apt" - ansible_pkg_mgr != "apt"
- ansible_pkg_mgr != "portage"
- not galera_upgrade - not galera_upgrade
- name: Run galera secure - name: Run galera secure
@ -62,6 +64,7 @@
warn: no warn: no
when: when:
- ansible_pkg_mgr != "apt" - ansible_pkg_mgr != "apt"
- ansible_pkg_mgr != "portage"
- not galera_upgrade - not galera_upgrade
tags: tags:
- skip_ansible_lint - skip_ansible_lint
@ -147,11 +150,20 @@
- Manage LB - Manage LB
- Restart all mysql - Restart all mysql
# Safe to run multiple times, config has it's own checks
- name: initialize database (gentoo)
command: "emerge --config dev-db/mariadb"
failed_when: false
when:
- ansible_pkg_mgr == 'portage'
- name: Apply service defaults - name: Apply service defaults
template: template:
src: "mysql_defaults.j2" src: "mysql_defaults.j2"
dest: "/etc/default/mariadb" dest: "/etc/default/mariadb"
mode: "0644" mode: "0644"
when:
- ansible_pkg_mgr != 'portage'
notify: notify:
- Manage LB - Manage LB
- Restart all mysql - Restart all mysql
@ -163,6 +175,8 @@
dest: "/etc/default/mysql" dest: "/etc/default/mysql"
state: "link" state: "link"
force: "yes" force: "yes"
when:
- ansible_pkg_mgr != 'portage'
- name: remove default mysql_safe_syslog - name: remove default mysql_safe_syslog
file: file:
@ -170,8 +184,8 @@
state: absent state: absent
- name: Create new cluster tool - name: Create new cluster tool
copy: template:
src: "galera_new_cluster" src: "galera_new_cluster.j2"
dest: "/usr/local/bin/galera_new_cluster" dest: "/usr/local/bin/galera_new_cluster"
mode: "0750" mode: "0750"

View File

@ -56,7 +56,7 @@
no_log: True no_log: True
- name: Run MySQL Upgrade - name: Run MySQL Upgrade
command: "/usr/bin/mysql_upgrade" command: "/usr/bin/mysql_upgrade -h 127.0.0.1"
register: galera_mysql_upgrade register: galera_mysql_upgrade
changed_when: changed_when:
- not galera_mysql_upgrade.stdout | search("already upgraded") - not galera_mysql_upgrade.stdout | search("already upgraded")

View File

@ -47,16 +47,16 @@ EOF
trap cleanup EXIT INT TERM trap cleanup EXIT INT TERM
EXIT_CODE=0 EXIT_CODE=0
if ! systemctl status mysql > /dev/null; then if ! systemctl status {{ mysql_service_name }}> /dev/null; then
systemctl set-environment _WSREP_NEW_CLUSTER='--wsrep-new-cluster' systemctl set-environment _WSREP_NEW_CLUSTER='--wsrep-new-cluster'
if grep -rniq -e suse -e opensuse /etc/os-release; then if grep -rniq -e suse -e opensuse /etc/os-release; then
bootstrap_opts bootstrap_opts
fi fi
if systemctl start mysql; then if systemctl start {{ mysql_service_name }}; then
EXIT_CODE=3 EXIT_CODE=3
else else
echo "Cluster bootstrap failed." echo "Cluster bootstrap failed."
systemctl status mysql systemctl status {{ mysql_service_name }}
exit 99 exit 99
fi fi
fi fi

View File

@ -17,12 +17,12 @@ set -ev
STOP_MYSQL=false STOP_MYSQL=false
if ! systemctl status mysql; then if ! systemctl status {{ mysql_service_name }}; then
STOP_MYSQL=true STOP_MYSQL=true
systemctl set-environment MYSQLD_OPTS="--bind-address=127.0.0.1" systemctl set-environment MYSQLD_OPTS="--bind-address=127.0.0.1"
systemctl start mysql systemctl start {{ mysql_service_name }}
sleep 10 sleep 10
systemctl status mysql systemctl status {{ mysql_service_name }}
fi fi
if mysqladmin --no-defaults --port=3306 --socket=/var/run/mysqld/mysqld.sock --host=127.0.0.1 --user=root password "{{ galera_root_password }}"; then if mysqladmin --no-defaults --port=3306 --socket=/var/run/mysqld/mysqld.sock --host=127.0.0.1 --user=root password "{{ galera_root_password }}"; then
@ -38,7 +38,7 @@ if mysqladmin --no-defaults --port=3306 --socket=/var/run/mysqld/mysqld.sock --h
fi fi
if [ "${STOP_MYSQL}" = true ]; then if [ "${STOP_MYSQL}" = true ]; then
systemctl stop mysql systemctl stop {{ mysql_service_name }}
fi fi
# Create a marker file to ensure this script is not run again # Create a marker file to ensure this script is not run again

View File

@ -29,6 +29,7 @@ collation-server = utf8_general_ci
init-connect = 'SET NAMES utf8' init-connect = 'SET NAMES utf8'
character-set-server = utf8 character-set-server = utf8
datadir = /var/lib/mysql datadir = /var/lib/mysql
tmpdir = /var/lib/mysql
bind-address = :: bind-address = ::
{% if galera_server_id is defined %} {% if galera_server_id is defined %}
server-id = {{ galera_server_id }} server-id = {{ galera_server_id }}

58
vars/gentoo.yml Normal file
View File

@ -0,0 +1,58 @@
---
# Copyright 2019, Matthew Thode
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
## APT Cache Options
cache_timeout: 600
# Default private device setting
_galera_disable_privatedevices: yes
galera_server_required_distro_packages:
- sys-apps/xinetd
galera_etc_conf_file: "/etc/mysql/my.cnf"
galera_etc_include_dir: "/etc/mysql/conf.d"
galera_var_run_socket: "/var/run/mysqld/mysqld.sock"
# The package name for mariaDB is set as a variable
# so that it can be used in debconf later in the
# "galera_common" role.
_galera_mariadb_server_package: "dev-db/mariadb"
# NB This is specifically galera_server_mariadb_distro_packages as these
# packages only get installed during the galera play - this is because of
# the preseed task and the service startup control used when installing
# mariadb-galera-server and galera.
galera_server_mariadb_distro_packages:
- "{{ galera_mariadb_server_package }}"
- sys-cluster/galera
- net-misc/rsync
- net-misc/socat
- dev-python/mysql-python
# The packages to uninstall during an upgrade from a previous version
galera_server_upgrade_packages_remove:
galera_mariadb_service_name: "mariadb"
galera_server_percona_distro_packages:
- dev-db/percona-toolkit
- dev-db/percona-xtrabackup-bin
- "{{ (galera_xtrabackup_compression | bool) | ternary('app-arch/qpress', '') }}"
galera_wsrep_provider: "/usr/lib64/galera/libgalera_smm.so"
_use_percona_upstream: no
mysql_service_name: mariadb

1
vars/main.yml Normal file
View File

@ -0,0 +1 @@
mysql_service_name: mysql