blob: bf62a85f4cced6e29804268ea021c23870fa3e82 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
---
- fail:
msg: "MariaDB cluster was not found. Is your inventory correct?"
when: delegate_host == 'None'
- name: Checking if and mariadb containers are running
kolla_docker:
name: "mariadb"
action: "get_container_state"
register: container_state
- fail:
msg: "There are running MariaDB nodes, please stop them first."
when: container_state.Running | bool
any_errors_fatal: True
- name: Cleaning up temp file on mariadb hosts
file: path=/tmp/kolla_mariadb_grastate.dat state=absent
changed_when: false
check_mode: no
- name: Cleaning up temp file on localhost
local_action: file path=/tmp/kolla_mariadb_recover_inventory_name state=absent
changed_when: false
check_mode: no
run_once: true
- block:
- name: Copying grastate.dat file from mariadb container
command: docker cp mariadb:/var/lib/mysql/grastate.dat /tmp/kolla_mariadb_grastate.dat
changed_when: false
- name: Print the content of grastate.dat file
command: cat /tmp/kolla_mariadb_grastate.dat
register: cat_grastate
changed_when: false
- name: Registering mariadb seqno variable
set_fact:
seqno: "{{ (cat_grastate.stdout|from_yaml).seqno }}"
changed_when: false
- name: Comparing seqno value on all mariadb hosts
shell: "if [[ {{ hostvars[inventory_hostname]['seqno'] }} -lt {{ hostvars[item]['seqno'] }} ]]; then echo {{ hostvars[item]['seqno'] }}; fi"
with_items: "{{ groups['mariadb'] }}"
changed_when: false
register: seqno_compare
- name: Writing hostname of host with the largest seqno to temp file
local_action: copy content={{ inventory_hostname }} dest=/tmp/kolla_mariadb_recover_inventory_name mode=0644
changed_when: false
when: seqno_compare.results | map(attribute='stdout') | join('') == ""
- name: Registering mariadb_recover_inventory_name from temp file
set_fact:
mariadb_recover_inventory_name: "{{ lookup('file', '/tmp/kolla_mariadb_recover_inventory_name') }}"
when:
- mariadb_recover_inventory_name is not defined
- name: Cleaning up temp file on mariadb hosts
file: path=/tmp/kolla_mariadb_grastate.dat state=absent
changed_when: false
check_mode: no
- name: Cleaning up temp file on localhost
local_action: file path=/tmp/kolla_mariadb_recover_inventory_name state=absent
changed_when: false
check_mode: no
run_once: true
- name: Starting first MariaDB container
kolla_docker:
action: "start_container"
common_options: "{{ docker_common_options }}"
environment:
KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
BOOTSTRAP_ARGS: "--wsrep-new-cluster"
image: "{{ mariadb_image_full }}"
labels:
BOOTSTRAP:
name: "mariadb"
restart_policy: "never"
volumes:
- "{{ node_config_directory }}/mariadb/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"
- "mariadb:/var/lib/mysql"
when:
- (mariadb_recover_inventory_name is not defined and inventory_hostname == groups['mariadb'][0]) or
(mariadb_recover_inventory_name is defined and inventory_hostname == mariadb_recover_inventory_name)
- name: Reset bootstrap fact
set_fact:
delegate_host: "None"
|