Skip to content

Commit

Permalink
cleanup: refactor into galera_mariadb_service_name
Browse files Browse the repository at this point in the history
We had two variable names which were duplicated for the service
name, this converges them all to "mariadb" which uses the actual
systemd unit instead of the init.d compatiblity layer.

Change-Id: I5805fb11a5118c4011701377cd30b2511edca505
  • Loading branch information
mnaser committed Jul 12, 2019
1 parent ea1f268 commit 7c7ade4
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 20 deletions.
1 change: 1 addition & 0 deletions defaults/main.yml
Expand Up @@ -37,6 +37,7 @@ galera_cluster_name: openstack_galera_cluster
# if these are used they should be set within the
# distro specific variable files found in vars/
galera_debconf_items: []
galera_mariadb_service_name: mariadb
galera_mariadb_server_package: "{{ _galera_mariadb_server_package }}"

# The major version used to select the repo URL path
Expand Down
4 changes: 2 additions & 2 deletions handlers/main.yml
Expand Up @@ -16,7 +16,7 @@
- name: Reload the systemd daemon
systemd:
daemon_reload: yes
name: "{{ mysql_service_name }}"
name: "{{ galera_mariadb_service_name }}"
enabled: "yes"

- name: Check node status
Expand Down Expand Up @@ -70,7 +70,7 @@

- name: Restart mysql (All)
service:
name: "{{ mysql_service_name }}"
name: "{{ galera_mariadb_service_name }}"
state: "{{ (not hostvars[item]['galera_cluster_ready'] | bool) | ternary('started', 'restarted') }}"
environment:
MYSQLD_STARTUP_TIMEOUT: 180
Expand Down
6 changes: 3 additions & 3 deletions templates/galera_new_cluster.j2
Expand Up @@ -47,16 +47,16 @@ EOF
trap cleanup EXIT INT TERM

EXIT_CODE=0
if ! systemctl status {{ mysql_service_name }}> /dev/null; then
if ! systemctl status {{ galera_mariadb_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_service_name }}; then
if systemctl start {{ galera_mariadb_service_name }}; then
EXIT_CODE=3
else
echo "Cluster bootstrap failed."
systemctl status {{ mysql_service_name }}
systemctl status {{ galera_mariadb_service_name }}
exit 99
fi
fi
Expand Down
8 changes: 4 additions & 4 deletions templates/galera_secure_node.j2
Expand Up @@ -17,12 +17,12 @@ set -ev

STOP_MYSQL=false

if ! systemctl status {{ mysql_service_name }}; then
if ! systemctl status {{ galera_mariadb_service_name }}; then
STOP_MYSQL=true
systemctl set-environment MYSQLD_OPTS="--bind-address=127.0.0.1"
systemctl start {{ mysql_service_name }}
systemctl start {{ galera_mariadb_service_name }}
sleep 10
systemctl status {{ mysql_service_name }}
systemctl status {{ galera_mariadb_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
Expand All @@ -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_service_name }}
systemctl stop {{ galera_mariadb_service_name }}
fi

# Create a marker file to ensure this script is not run again
Expand Down
2 changes: 0 additions & 2 deletions vars/debian.yml
Expand Up @@ -64,8 +64,6 @@ galera_server_upgrade_packages_remove:
- mariadb-server
- mysql-common

galera_mariadb_service_name: "mariadb"

galera_debconf_items:
- question: "mysql-server/root_password"
name: "{{ galera_mariadb_server_package }}"
Expand Down
4 changes: 0 additions & 4 deletions vars/gentoo.yml
Expand Up @@ -45,8 +45,4 @@ galera_server_mariadb_distro_packages:
# The packages to uninstall during an upgrade from a previous version
galera_server_upgrade_packages_remove:

galera_mariadb_service_name: "mariadb"

galera_wsrep_provider: "/usr/lib64/galera/libgalera_smm.so"

mysql_service_name: mariadb
1 change: 0 additions & 1 deletion vars/main.yml

This file was deleted.

2 changes: 0 additions & 2 deletions vars/redhat.yml
Expand Up @@ -60,8 +60,6 @@ galera_server_upgrade_packages_remove:
- MariaDB-Galera-server
- MariaDB-server

galera_mariadb_service_name: "mariadb"

_galera_repo_url: "http://{{ galera_repo_host }}/MariaDB/mariadb-{{ galera_client_major_version }}.{{ galera_client_minor_version }}/yum/{{ ansible_distribution | lower }}{{ ansible_distribution_major_version }}-amd64/"
_galera_repo:
name: MariaDB
Expand Down
2 changes: 0 additions & 2 deletions vars/suse.yml
Expand Up @@ -58,8 +58,6 @@ galera_server_upgrade_packages_remove:
- MariaDB-Galera-server
- MariaDB-server

galera_mariadb_service_name: "mariadb"

_galera_opensuse_dir: "{{ ansible_distribution_major_version }}"
_galera_repo_url: "http://{{ galera_repo_host }}/MariaDB/mariadb-{{ galera_major_version }}.{{ galera_minor_version }}/yum/opensuse{{ _galera_opensuse_dir }}-amd64"
_galera_repo:
Expand Down

0 comments on commit 7c7ade4

Please sign in to comment.