Browse Source

Add gentoo support to galera_server

Depends-On: https://review.openstack.org/633289
Change-Id: I1ba3630e3f673aab419ebaff966f88868560df3b
Matthew Thode 2 months ago
parent
commit
ccf108ed24
No account linked to committer's email address

+ 2
- 2
handlers/main.yml View File

@@ -16,7 +16,7 @@
16 16
 - name: Reload the systemd daemon
17 17
   systemd:
18 18
     daemon_reload: yes
19
-    name: mysql
19
+    name: "{{ mysql_service_name }}"
20 20
     enabled: "yes"
21 21
 
22 22
 - name: Check node status
@@ -70,7 +70,7 @@
70 70
 
71 71
 - name: Restart mysql (All)
72 72
   service:
73
-    name: mysql
73
+    name: "{{ mysql_service_name }}"
74 74
     state: "{{ (not hostvars[item]['galera_cluster_ready'] | bool) | ternary('started', 'restarted') }}"
75 75
   environment:
76 76
     MYSQLD_STARTUP_TIMEOUT: 180

+ 39
- 0
tasks/galera_install_portage.yml View File

@@ -0,0 +1,39 @@
1
+---
2
+# Copyright 2019, Matthew Thode
3
+#
4
+# Licensed under the Apache License, Version 2.0 (the "License");
5
+# you may not use this file except in compliance with the License.
6
+# You may obtain a copy of the License at
7
+#
8
+#     http://www.apache.org/licenses/LICENSE-2.0
9
+#
10
+# Unless required by applicable law or agreed to in writing, software
11
+# distributed under the License is distributed on an "AS IS" BASIS,
12
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+# See the License for the specific language governing permissions and
14
+# limitations under the License.
15
+
16
+- name: Install galera_server role packages
17
+  package:
18
+    name: "{{ galera_packages_list }}"
19
+    state: "{{ galera_server_package_state }}"
20
+    newuse: "{{ (ansible_pkg_mgr == 'portage') | ternary('yes', omit) }}"
21
+    changed_use: "{{ (ansible_pkg_mgr == 'portage') | ternary('yes', omit) }}"
22
+    noreplace: "{{ (ansible_pkg_mgr == 'portage') | ternary('yes', omit) }}"
23
+    jobs: "{{ (ansible_pkg_mgr == 'portage') | ternary('4', omit) }}"
24
+  register: install_remote_packages
25
+  until: install_remote_packages is success
26
+  retries: 5
27
+  delay: 2
28
+
29
+- name: Ensure mysql config directories exists
30
+  file:
31
+    src: "{{ item.src | default(omit) }}"
32
+    path: "{{ item.path }}"
33
+    state: "{{ item.state }}"
34
+    force: "{{ item.force | default(omit) }}"
35
+  with_items:
36
+    - path: "/etc/mysql"
37
+      state: "directory"
38
+    - path: "{{ galera_etc_include_dir }}"
39
+      state: "directory"

+ 16
- 2
tasks/galera_post_install.yml View File

@@ -46,6 +46,7 @@
46 46
 #                  as all of these tasks will be run on Package install
47 47
 #                  and running them again will cause a conflict within
48 48
 #                  debian based deployments.
49
+# NOTE(prometheanfire): Ditto Gentoo ^
49 50
 - name: Create galera initial secure tool
50 51
   template:
51 52
     src: "galera_secure_node.j2"
@@ -53,6 +54,7 @@
53 54
     mode: "0750"
54 55
   when:
55 56
     - ansible_pkg_mgr != "apt"
57
+    - ansible_pkg_mgr != "portage"
56 58
     - not galera_upgrade
57 59
 
58 60
 - name: Run galera secure
@@ -62,6 +64,7 @@
62 64
     warn: no
63 65
   when:
64 66
     - ansible_pkg_mgr != "apt"
67
+    - ansible_pkg_mgr != "portage"
65 68
     - not galera_upgrade
66 69
   tags:
67 70
     - skip_ansible_lint
@@ -147,11 +150,20 @@
147 150
     - Manage LB
148 151
     - Restart all mysql
149 152
 
153
+# Safe to run multiple times, config has it's own checks
154
+- name: initialize database (gentoo)
155
+  command: "emerge --config dev-db/mariadb"
156
+  failed_when: false
157
+  when:
158
+    - ansible_pkg_mgr == 'portage'
159
+
150 160
 - name: Apply service defaults
151 161
   template:
152 162
     src: "mysql_defaults.j2"
153 163
     dest: "/etc/default/mariadb"
154 164
     mode: "0644"
165
+  when:
166
+    - ansible_pkg_mgr != 'portage'
155 167
   notify:
156 168
     - Manage LB
157 169
     - Restart all mysql
@@ -163,6 +175,8 @@
163 175
     dest: "/etc/default/mysql"
164 176
     state: "link"
165 177
     force: "yes"
178
+  when:
179
+    - ansible_pkg_mgr != 'portage'
166 180
 
167 181
 - name: remove default mysql_safe_syslog
168 182
   file:
@@ -170,8 +184,8 @@
170 184
     state: absent
171 185
 
172 186
 - name: Create new cluster tool
173
-  copy:
174
-    src: "galera_new_cluster"
187
+  template:
188
+    src: "galera_new_cluster.j2"
175 189
     dest: "/usr/local/bin/galera_new_cluster"
176 190
     mode: "0750"
177 191
 

+ 1
- 1
tasks/galera_setup.yml View File

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

files/galera_new_cluster → templates/galera_new_cluster.j2 View File

@@ -47,16 +47,16 @@ EOF
47 47
 trap cleanup EXIT INT TERM
48 48
 
49 49
 EXIT_CODE=0
50
-if ! systemctl status mysql > /dev/null; then
50
+if ! systemctl status {{ mysql_service_name }}> /dev/null; then
51 51
   systemctl set-environment _WSREP_NEW_CLUSTER='--wsrep-new-cluster'
52 52
   if grep -rniq -e suse -e opensuse /etc/os-release; then
53 53
     bootstrap_opts
54 54
   fi
55
-  if systemctl start mysql; then
55
+  if systemctl start {{ mysql_service_name }}; then
56 56
     EXIT_CODE=3
57 57
   else
58 58
     echo "Cluster bootstrap failed."
59
-    systemctl status mysql
59
+    systemctl status {{ mysql_service_name }}
60 60
     exit 99
61 61
   fi
62 62
 fi

+ 4
- 4
templates/galera_secure_node.j2 View File

@@ -17,12 +17,12 @@ set -ev
17 17
 
18 18
 STOP_MYSQL=false
19 19
 
20
-if ! systemctl status mysql; then
20
+if ! systemctl status {{ mysql_service_name }}; then
21 21
   STOP_MYSQL=true
22 22
   systemctl set-environment MYSQLD_OPTS="--bind-address=127.0.0.1"
23
-  systemctl start mysql
23
+  systemctl start {{ mysql_service_name }}
24 24
   sleep 10
25
-  systemctl status mysql
25
+  systemctl status {{ mysql_service_name }}
26 26
 fi
27 27
 
28 28
 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
38 38
 fi
39 39
 
40 40
 if [ "${STOP_MYSQL}" = true ]; then
41
-  systemctl stop mysql
41
+  systemctl stop {{ mysql_service_name }}
42 42
 fi
43 43
 
44 44
 # Create a marker file to ensure this script is not run again

+ 1
- 0
templates/my.cnf.j2 View File

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

+ 58
- 0
vars/gentoo.yml View File

@@ -0,0 +1,58 @@
1
+---
2
+# Copyright 2019, Matthew Thode
3
+#
4
+# Licensed under the Apache License, Version 2.0 (the "License");
5
+# you may not use this file except in compliance with the License.
6
+# You may obtain a copy of the License at
7
+#
8
+#     http://www.apache.org/licenses/LICENSE-2.0
9
+#
10
+# Unless required by applicable law or agreed to in writing, software
11
+# distributed under the License is distributed on an "AS IS" BASIS,
12
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+# See the License for the specific language governing permissions and
14
+# limitations under the License.
15
+
16
+## APT Cache Options
17
+cache_timeout: 600
18
+
19
+# Default private device setting
20
+_galera_disable_privatedevices: yes
21
+
22
+galera_server_required_distro_packages:
23
+  - sys-apps/xinetd
24
+
25
+galera_etc_conf_file: "/etc/mysql/my.cnf"
26
+galera_etc_include_dir: "/etc/mysql/conf.d"
27
+galera_var_run_socket: "/var/run/mysqld/mysqld.sock"
28
+
29
+# The package name for mariaDB is set as a variable
30
+# so that it can be used in debconf later in the
31
+# "galera_common" role.
32
+_galera_mariadb_server_package: "dev-db/mariadb"
33
+
34
+# NB This is specifically galera_server_mariadb_distro_packages as these
35
+# packages only get installed during the galera play - this is because of
36
+# the preseed task and the service startup control used when installing
37
+# mariadb-galera-server and galera.
38
+galera_server_mariadb_distro_packages:
39
+  - "{{ galera_mariadb_server_package }}"
40
+  - sys-cluster/galera
41
+  - net-misc/rsync
42
+  - net-misc/socat
43
+  - dev-python/mysql-python
44
+
45
+# The packages to uninstall during an upgrade from a previous version
46
+galera_server_upgrade_packages_remove:
47
+
48
+galera_mariadb_service_name: "mariadb"
49
+
50
+galera_server_percona_distro_packages:
51
+  - dev-db/percona-toolkit
52
+  - dev-db/percona-xtrabackup-bin
53
+  - "{{ (galera_xtrabackup_compression | bool) | ternary('app-arch/qpress', '') }}"
54
+
55
+galera_wsrep_provider: "/usr/lib64/galera/libgalera_smm.so"
56
+
57
+_use_percona_upstream: no
58
+mysql_service_name: mariadb

+ 1
- 0
vars/main.yml View File

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

Loading…
Cancel
Save