Merge "Add gentoo support to galera_server"
This commit is contained in:
commit
152ae31478
@ -16,7 +16,7 @@
|
||||
- name: Reload the systemd daemon
|
||||
systemd:
|
||||
daemon_reload: yes
|
||||
name: mysql
|
||||
name: "{{ mysql_service_name }}"
|
||||
enabled: "yes"
|
||||
|
||||
- name: Check node status
|
||||
@ -70,7 +70,7 @@
|
||||
|
||||
- name: Restart mysql (All)
|
||||
service:
|
||||
name: mysql
|
||||
name: "{{ mysql_service_name }}"
|
||||
state: "{{ (not hostvars[item]['galera_cluster_ready'] | bool) | ternary('started', 'restarted') }}"
|
||||
environment:
|
||||
MYSQLD_STARTUP_TIMEOUT: 180
|
||||
|
39
tasks/galera_install_portage.yml
Normal file
39
tasks/galera_install_portage.yml
Normal 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"
|
@ -46,6 +46,7 @@
|
||||
# as all of these tasks will be run on Package install
|
||||
# and running them again will cause a conflict within
|
||||
# debian based deployments.
|
||||
# NOTE(prometheanfire): Ditto Gentoo ^
|
||||
- name: Create galera initial secure tool
|
||||
template:
|
||||
src: "galera_secure_node.j2"
|
||||
@ -53,6 +54,7 @@
|
||||
mode: "0750"
|
||||
when:
|
||||
- ansible_pkg_mgr != "apt"
|
||||
- ansible_pkg_mgr != "portage"
|
||||
- not galera_upgrade
|
||||
|
||||
- name: Run galera secure
|
||||
@ -62,6 +64,7 @@
|
||||
warn: no
|
||||
when:
|
||||
- ansible_pkg_mgr != "apt"
|
||||
- ansible_pkg_mgr != "portage"
|
||||
- not galera_upgrade
|
||||
tags:
|
||||
- skip_ansible_lint
|
||||
@ -147,11 +150,20 @@
|
||||
- Manage LB
|
||||
- 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
|
||||
template:
|
||||
src: "mysql_defaults.j2"
|
||||
dest: "/etc/default/mariadb"
|
||||
mode: "0644"
|
||||
when:
|
||||
- ansible_pkg_mgr != 'portage'
|
||||
notify:
|
||||
- Manage LB
|
||||
- Restart all mysql
|
||||
@ -163,6 +175,8 @@
|
||||
dest: "/etc/default/mysql"
|
||||
state: "link"
|
||||
force: "yes"
|
||||
when:
|
||||
- ansible_pkg_mgr != 'portage'
|
||||
|
||||
- name: remove default mysql_safe_syslog
|
||||
file:
|
||||
@ -170,8 +184,8 @@
|
||||
state: absent
|
||||
|
||||
- name: Create new cluster tool
|
||||
copy:
|
||||
src: "galera_new_cluster"
|
||||
template:
|
||||
src: "galera_new_cluster.j2"
|
||||
dest: "/usr/local/bin/galera_new_cluster"
|
||||
mode: "0750"
|
||||
|
||||
|
@ -56,7 +56,7 @@
|
||||
no_log: True
|
||||
|
||||
- name: Run MySQL Upgrade
|
||||
command: "/usr/bin/mysql_upgrade"
|
||||
command: "/usr/bin/mysql_upgrade -h 127.0.0.1"
|
||||
register: galera_mysql_upgrade
|
||||
changed_when:
|
||||
- not galera_mysql_upgrade.stdout is search("already upgraded")
|
||||
|
@ -47,16 +47,16 @@ EOF
|
||||
trap cleanup EXIT INT TERM
|
||||
|
||||
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'
|
||||
if grep -rniq -e suse -e opensuse /etc/os-release; then
|
||||
bootstrap_opts
|
||||
fi
|
||||
if systemctl start mysql; then
|
||||
if systemctl start {{ mysql_service_name }}; then
|
||||
EXIT_CODE=3
|
||||
else
|
||||
echo "Cluster bootstrap failed."
|
||||
systemctl status mysql
|
||||
systemctl status {{ mysql_service_name }}
|
||||
exit 99
|
||||
fi
|
||||
fi
|
@ -17,12 +17,12 @@ set -ev
|
||||
|
||||
STOP_MYSQL=false
|
||||
|
||||
if ! systemctl status mysql; then
|
||||
if ! systemctl status {{ mysql_service_name }}; then
|
||||
STOP_MYSQL=true
|
||||
systemctl set-environment MYSQLD_OPTS="--bind-address=127.0.0.1"
|
||||
systemctl start mysql
|
||||
systemctl start {{ mysql_service_name }}
|
||||
sleep 10
|
||||
systemctl status mysql
|
||||
systemctl status {{ mysql_service_name }}
|
||||
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
|
||||
@ -38,7 +38,7 @@ if mysqladmin --no-defaults --port=3306 --socket=/var/run/mysqld/mysqld.sock --h
|
||||
fi
|
||||
|
||||
if [ "${STOP_MYSQL}" = true ]; then
|
||||
systemctl stop mysql
|
||||
systemctl stop {{ mysql_service_name }}
|
||||
fi
|
||||
|
||||
# Create a marker file to ensure this script is not run again
|
||||
|
@ -29,6 +29,7 @@ collation-server = utf8_general_ci
|
||||
init-connect = 'SET NAMES utf8'
|
||||
character-set-server = utf8
|
||||
datadir = /var/lib/mysql
|
||||
tmpdir = /var/lib/mysql
|
||||
bind-address = ::
|
||||
{% if galera_server_id is defined %}
|
||||
server-id = {{ galera_server_id }}
|
||||
|
58
vars/gentoo.yml
Normal file
58
vars/gentoo.yml
Normal 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
1
vars/main.yml
Normal file
@ -0,0 +1 @@
|
||||
mysql_service_name: mysql
|
Loading…
Reference in New Issue
Block a user