-
Notifications
You must be signed in to change notification settings - Fork 2
/
create-bricks.yml
108 lines (93 loc) · 3.34 KB
/
create-bricks.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
---
- name: Create bricks
hosts: moosefs_chunkserver
become: true
vars_files:
- "vars/moosefs-settings.yml"
pre_tasks:
- name: Show disclaimer
debug:
msg:
- "Welcome to MooseFS! This is a helper script, designed to allow you to automatically discover and prepare 'bricks' - disks on which
MooseFS data is stored - for use with MooseFS."
- ""
- "IMPORTANT NOTE: You should be aware this procedure is not safe to run on servers with with non-MooseFS disks attached."
- "It will try to avoid doing anything dangerous, but for the safety of your data, please only use this to initialise new chunkservers."
- "For more information, feel free to contact the authors or ask the MooseFS team."
# - name: Check if user is ready
# pause:
# prompt: "Are you sure you wish to continue? Press [ENTER] to continue or press [CTRL-C] to cancel."
- name: Ensure dependencies are installed
package:
name:
- xfsprogs
- e2fsprogs
state: present
- name: Print list of disks
debug:
msg: "{{ item }}"
when:
- not item.value.partitions
- not item.value.holders
- "'sd' in item.key or 'xvd' in item.key"
loop: "{{ ansible_devices | dict2items }}"
- name: Gather list of disks
set_fact:
disks: "{{ disks|default([]) + [item.key]}}"
when:
- not item.value.partitions
- not item.value.holders
- "'sd' in item.key or 'xvd' in item.key"
loop: "{{ ansible_devices | dict2items }}"
no_log: true
# TODO: Check list of disks for mounted partitions.
# We can check {{ ansible_mounts }}, then check if a device starts with item.key
# - name: Print list
# pause:
# prompt: "The following disks will be affected: {{ disks }} Press [ENTER] to continue or press [CTRL-C] to cancel."
- name: Create bricks (xfs)
community.general.filesystem:
fstype: xfs
dev: "/dev/{{ item }}"
state: present
loop: "{{ disks }}"
when: moosefs_brick_fstype|lower == 'xfs'
- name: Create bricks (ext4)
community.general.filesystem:
fstype: xfs
dev: "/dev/{{ item }}"
state: present
loop: "{{ disks }}"
when: moosefs_brick_fstype|lower == 'ext4'
- name: Gather facts again
setup:
- name: Gather UUIDs from bricks
set_fact:
uuids: "{{ uuids|default([]) + [ {'name': item.key, 'uuid': item.value.links.uuids} ]}}"
when:
- not item.value.partitions
- not item.value.holders
- "'sd' in item.key or 'xvd' in item.key"
- item.key in disks
loop: "{{ ansible_devices | dict2items }}"
no_log: true
- name: Create mountpoints for bricks
file:
path: "/mnt/mfsbrick.{{ item.uuid[0] }}"
state: directory
owner: root
group: root
mode: 0755
loop: "{{ uuids }}"
- name: Mount the bricks
mount:
path: "/mnt/mfsbrick.{{ item.uuid[0] }}"
src: "UUID={{ item.uuid[0] }}"
fstype: "{{ moosefs_brick_fstype|lower }}"
opts: nofail
state: mounted
loop: "{{ uuids }}"
- name: Print a success message
debug:
msg:
- "Successfully created bricks. Your chunkservers should be ready to use."