
Since ansible-core 2.10 it is recommended to use modules via FQCN In order to align with recommendation, we perform migration by applying suggestions made by `ansible-lint --fix=fqcn` Change-Id: I1ba53c1b0cc33cf7cad8057481275f5757c28b0a
108 lines
3.3 KiB
YAML
108 lines
3.3 KiB
YAML
---
|
|
# Copyright 2015, Rackspace US, Inc.
|
|
#
|
|
# 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: Check node status
|
|
ansible.builtin.command: >
|
|
{{ galera_mariadb_client_binary }} --silent --skip-column-names --connect-timeout=10 -e 'SHOW STATUS LIKE "wsrep_local_state";'
|
|
failed_when: false
|
|
changed_when: false
|
|
register: node_status
|
|
listen:
|
|
- Restart all mysql
|
|
- cert installed
|
|
|
|
- name: Check if node is in the cluster
|
|
ansible.builtin.command: >
|
|
{{ galera_mariadb_client_binary }} --silent --skip-column-names --connect-timeout=10 -e 'SHOW STATUS LIKE "wsrep_incoming_addresses";'
|
|
failed_when: false
|
|
changed_when: false
|
|
register: incoming_addresses
|
|
listen:
|
|
- Restart all mysql
|
|
- cert installed
|
|
|
|
- name: Set incoming addresses fact (primary)
|
|
ansible.builtin.set_fact:
|
|
galera_incoming_addresses: "{{ (incoming_addresses.stdout.split()[-1] | default('')).split(',') }}"
|
|
listen:
|
|
- Restart all mysql
|
|
- cert installed
|
|
|
|
- name: Set node status fact
|
|
ansible.builtin.set_fact:
|
|
galera_cluster_ready: "{{ (galera_wsrep_address_port in galera_incoming_addresses) or ((node_status.stdout.split()[-1] | default(false)) in ['2', '4']) }}"
|
|
listen:
|
|
- Restart all mysql
|
|
- cert installed
|
|
|
|
- name: Stop mysql
|
|
ansible.builtin.service:
|
|
name: "{{ galera_mariadb_service_name }}"
|
|
state: stopped
|
|
enabled: true
|
|
changed_when: true
|
|
listen:
|
|
- Restart all mysql
|
|
- cert installed
|
|
when:
|
|
- galera_install_server | bool
|
|
- not galera_cluster_ready | bool or galera_force_bootstrap | bool
|
|
|
|
- name: Start new cluster
|
|
ansible.builtin.command: /usr/local/bin/galera_new_cluster
|
|
failed_when: not start_new_cluster.rc in [0, 3]
|
|
changed_when: start_new_cluster.rc == 3
|
|
register: start_new_cluster
|
|
delegate_to: "{{ galera_server_bootstrap_node }}"
|
|
run_once: true
|
|
when:
|
|
- galera_install_server | bool
|
|
- not galera_cluster_ready | bool or galera_force_bootstrap | bool
|
|
listen:
|
|
- Restart all mysql
|
|
- cert installed
|
|
|
|
- name: Restart mysql (All)
|
|
ansible.builtin.service:
|
|
name: "{{ galera_mariadb_service_name }}"
|
|
state: "{{ (not hostvars[item]['galera_cluster_ready'] | bool or galera_force_bootstrap | bool) | ternary('started', 'restarted') }}"
|
|
enabled: true
|
|
environment:
|
|
MYSQLD_STARTUP_TIMEOUT: 180
|
|
register: galera_restart
|
|
until: galera_restart is success
|
|
retries: 6
|
|
delay: 5
|
|
delegate_to: "{{ item }}"
|
|
when:
|
|
- galera_install_server | bool
|
|
- hostvars[item]['galera_cluster_ready'] is defined
|
|
- hostvars[item]['galera_deployed'] | default(false) | bool
|
|
with_items:
|
|
- "{{ ansible_play_hosts }}"
|
|
run_once: true
|
|
listen:
|
|
- Restart all mysql
|
|
- cert installed
|
|
|
|
- name: Delete encryption keyfile after starting Galera
|
|
ansible.builtin.file:
|
|
path: "/tmp/.keyfile.key"
|
|
state: absent
|
|
when: galera_restart is changed
|
|
listen:
|
|
- Restart all mysql
|
|
- cert installed
|