-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpro-upgrade.yml
139 lines (119 loc) · 5.22 KB
/
pro-upgrade.yml
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
---
# This is a special playbook intended to allow you to automatically upgrade
# from MooseFS CE to MooseFS PRO.
# Status: EARLY DEVELOPMENT
- name: Preparation phase
hosts: moosefs
become: true
vars:
moosefs_pro_licenced: false
vars_files:
- "vars/moosefs-settings.yml"
- "vars/upgrade-settings.yml"
pre_tasks:
# TODO: Move this check to use mfscli -v instead
- name: Check MooseFS version
shell:
cmd: "mfscli -SIG -H {{ moosefs_master_host }} -p -s ' ' | grep 'master version' | cut -d' ' -f5"
register: moosefs_version_detected
changed_when: false
- name: Check if MooseFS version is within range for upgrade
ansible.builtin.assert:
that:
- "{{ moosefs_version_detected.stdout is version('3.0', '>=') }}"
- "{{ moosefs_version_detected.stdout is version('4.0', '<') }}"
fail_msg: "MooseFS version is out of range or unknown. Please ask for help."
success_msg: "MooseFS version detected appears valid for upgrade."
when: inventory_hostname == ansible_play_hosts[0]
- name: Check that MooseFS Pro is enabled and that we're using official packages
ansible.builtin.assert:
that:
- moosefs_pro == true
- moosefs_install_method == "official"
fail_msg: "Please enable MooseFS Pro in vars/moosefs-settings.yml and ensure install method is set to 'official'."
success_msg: "MooseFS Pro is enabled and the official installation method is selected."
- name: Check that we have a licence and that it is of non-zero length.
set_fact:
moosefs_pro_licenced: true
when: "((playbook_dir, 'mfslicence.bin') | path_join) is file"
- name: Fail if unlicenced
ansible.builtin.assert:
that:
- moosefs_pro_licenced == true
fail_msg: "You don't appear to have a MooseFS Pro licence. Please place one in the root of the playbook and try again."
success_msg: "You appear to have a MooseFS Pro licence file. Continuing!"
when: inventory_hostname == ansible_play_hosts[0]
- name: Check the state of the chunk matrix
command: mfscli -SIC -H {{ moosefs_master_host }} -p -s ' '
register: moosefs_chunks_status
check_mode: false
changed_when: false
when: inventory_hostname == ansible_play_hosts[0]
- name: Check the version of the chunkservers
shell: "mfscli -SCS -H {{ moosefs_master_host }} -p -s ' ' | cut -d' ' -f7"
register: moosefs_chunkserver_status
check_mode: false
changed_when: false
when: inventory_hostname == ansible_play_hosts[0]
- name: Check chunkserver's MooseFS version is within range for upgrade
ansible.builtin.assert:
that:
- "{{ item is version('3.0', '>=') }}"
- "{{ item is version('4.0', '<') }}"
loop: "{{ moosefs_chunkserver_status.stdout.splitlines() }}"
when: inventory_hostname == ansible_play_hosts[0]
- name: Determine the current state of the chunk matrix
set_fact:
moosefs_chunks_missing: "{{ moosefs_chunks_status.stdout_lines | select('search', 'chunkclass missing:') | select('search', ': 0') | length == 0 }}"
moosefs_chunks_endangered: "{{ moosefs_chunks_status.stdout_lines | select('search', 'chunkclass endangered:') | select('search', ': 0') | length == 0 }}"
moosefs_chunks_undergoal: "{{ moosefs_chunks_status.stdout_lines | select('search', 'chunkclass undergoal:') | select('search', ': 0') | length == 0 }}"
when: inventory_hostname == ansible_play_hosts[0]
- name: Print the current state of the chunk matrix
debug:
msg:
- "Chunks missing? {{ moosefs_chunks_missing }}"
- "Chunks endangered? {{ moosefs_chunks_endangered }}"
- "Chunks undergoal? {{ moosefs_chunks_undergoal }}"
when: inventory_hostname == ansible_play_hosts[0]
tasks:
- name: Check if MooseFS appears to have been installed using source method
stat:
path: /usr/local/src/moosefs-{{ moosefs_version_detected.stdout }}/moosefs-{{ moosefs_version_detected.stdout }}
register: moosefs_source_installed
- name: Uninstall MooseFS (source)
command:
cmd: make uninstall
chdir: /usr/local/src/moosefs-{{ moosefs_version_detected.stdout }}/moosefs-{{ moosefs_version_detected.stdout }}
when: moosefs_source_installed.stat.exists
- name: Uninstall MooseFS (official/package)
package:
name:
- moosefs-master
- moosefs-metalogger
- moosefs-chunkserver
- moosefs-client
- moosefs-cli
- moosefs-cgi
- moosefs-cgiserv
state: absent
- name: Install new MooseFS binaries
import_playbook: site.yml
vars:
moosefs_upgrade: true
- name: Restart metaloggers
import_playbook: rolling-metalogger.yml
vars:
moosefs_upgrade: true
# We upgrade the chunkservers *before* the master... to allow the chunkservers to
# elect a leader.
- name: Restart chunkservers
import_playbook: rolling-chunkserver.yml
vars:
moosefs_upgrade: true
- name: Restart masters
import_playbook: rolling-master.yml
vars:
moosefs_upgrade: true
moosefs_ce_to_pro_upgrade: true
- name: Restart clients
import_playbook: rolling-clients.yml