-
Notifications
You must be signed in to change notification settings - Fork 36
/
fscreate.yml
140 lines (133 loc) · 5.7 KB
/
fscreate.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
---
# If disktype is RAID we use the options:
# -f -K -i size=512 -d sw=%s,su=%sk -n size=8192 where sw is the diskcount and
# su is the stripe_unit_size
- name: Set XFS options for JBOD
set_fact:
fs_options: " -f -K -i size=512 -n size=8192 "
- name: Set XFS options for RAID devices
set_fact:
raid_options:
" -d sw={{ gluster_infra_diskcount }},\
su={{ gluster_infra_stripe_unit_size }}k "
when: >
gluster_infra_disktype == 'RAID6' or
gluster_infra_disktype == 'RAID10' or
gluster_infra_disktype == 'RAID5'
- name: Check if thin block devices exists
shell: >
{%if (item.pvs is defined) %}
{% for pvsname in item.pvs.split(",") %}
test -b {{ pvsname }} && echo "1" || echo "0";
{% endfor %}
{% else %}
echo "1"
{% endif %}
register: lvt_device_exists
with_items: "{{ gluster_infra_lv_logicalvols }}"
when: gluster_infra_lv_logicalvols is defined and item is not none
# We support only XFS. Filesysem options sw, su are specific to XFS
- name: Create filesystem on thin logical vols
command: "mkfs.xfs -f {{- fs_options -}}
{{- raid_options | default('') -}}
{% if raid_options is not defined
and item.raid is defined and item.raid is not none
and item.raid.level is defined and item.raid.devices is defined and item.raid.stripe is defined
and item.raid.level in [0,5,6,10]%}
{% if item.raid.level == 0 %}
{{ '-d sw=' ~ (item.raid.devices|int)|int}}
{% elif item.raid.level == 5 %}
{{ '-d sw=' ~ (item.raid.devices|int-1)|int }}
{% elif item.raid.level == 6 %}
{{ '-d sw=' ~ (item.raid.devices|int-2)|int }}
{% elif item.raid.level == 10 %}
{{ '-d sw=' ~ (item.raid.devices|int/2)|int}}
{% endif %}
{{ ' -d ,su=' ~ (item.raid.stripe|int) ~ 'k' }}
{% endif %} /dev/{{ item.vgname }}/{{ item.lvname }}"
# filesystem:
# fstype: xfs
# dev: "/dev/{{ item.vgname }}/{{ item.lvname }}"
# opts: >-
# {{- fs_options -}}
# {{- raid_options | default('') -}}
# {% if raid_options is not defined
# and item.raid is defined and item.raid is not none
# and item.raid.level is defined and item.raid.devices is defined and item.raid.stripe is defined
# and item.raid.level in [0,5,6,10]%}
# {% if item.raid.level == 0 %}
# {{ '-d sw=' ~ (item.raid.devices|int)|int}}
# {% elif item.raid.level == 5 %}
# {{ '-d sw=' ~ (item.raid.devices|int-1)|int }}
# {% elif item.raid.level == 6 %}
# {{ '-d sw=' ~ (item.raid.devices|int-2)|int }}
# {% elif item.raid.level == 10 %}
# {{ '-d sw=' ~ (item.raid.devices|int/2)|int}}
# {% endif %}
# {{ " -d su=" ~ (item.raid.stripe|int) ~ "k" }}
# {% endif %}
# force: "{{ gluster_infra_fs_force | default('no') }}"
with_items: "{{ (gluster_infra_lv_logicalvols is not none and gluster_infra_lv_logicalvols) or [] }}"
loop_control:
index_var: index
when: >
gluster_infra_lv_logicalvols is defined and (item.skipfs is not defined or not item.skipfs)
and lvt_device_exists.results[index].stdout_lines is defined and "0" not in lvt_device_exists.results[index].stdout_lines
- name: Check if thick block devices exists
shell: >
{%if (item.pvs is defined) %}
{% for pvsname in item.pvs.split(",") %}
test -b {{ pvsname }} && echo "1" || echo "0";
{% endfor %}
{% else %}
echo "1"
{% endif %}
register: lv_device_exists
with_items: "{{ gluster_infra_thick_lvs }}"
when: gluster_infra_thick_lvs is defined and item is not none
- name: Create filesystem on thick logical vols
command: "mkfs.xfs -f {{- fs_options -}}
{{- raid_options | default('') -}}
{% if raid_options is not defined
and item.raid is defined and item.raid is not none
and item.raid.level is defined and item.raid.devices is defined and item.raid.stripe is defined
and item.raid.level in [0,5,6,10]%}
{% if item.raid.level == 0 %}
{{ '-d sw=' ~ (item.raid.devices|int)|int}}
{% elif item.raid.level == 5 %}
{{ '-d sw=' ~ (item.raid.devices|int-1)|int }}
{% elif item.raid.level == 6 %}
{{ '-d sw=' ~ (item.raid.devices|int-2)|int }}
{% elif item.raid.level == 10 %}
{{ '-d sw=' ~ (item.raid.devices|int/2)|int}}
{% endif %}
{{ ' -d ,su=' ~ (item.raid.stripe|int) ~ 'k' }}
{% endif %} /dev/{{ item.vgname }}/{{ item.lvname }}"
# filesystem:
# fstype: xfs
# dev: "/dev/{{ item.vgname }}/{{ item.lvname }}"
# opts: >-
# {{- fs_options -}}
# {{- raid_options | default('') -}}
# {% if raid_options is not defined
# and item.raid is defined and item.raid is not none
# and item.raid.level is defined and item.raid.devices is defined and item.raid.stripe is defined
# and item.raid.level in [0,5,6,10]%}
# {% if item.raid.level == 0 %}
# {{ '-d sw=' ~ (item.raid.devices|int)|int}}
# {% elif item.raid.level == 5 %}
# {{ '-d sw=' ~ (item.raid.devices|int-1)|int }}
# {% elif item.raid.level == 6 %}
# {{ '-d sw=' ~ (item.raid.devices|int-2)|int }}
# {% elif item.raid.level == 10 %}
# {{ '-d sw=' ~ (item.raid.devices|int/2)|int}}
# {% endif %}
# {{ " -d su=" ~ (item.raid.stripe|int) ~ "k" }}
# {% endif %}
# force: "{{ gluster_infra_fs_force | default('no') }}"
with_items: "{{ (gluster_infra_thick_lvs is not none and gluster_infra_thick_lvs) or [] }}"
loop_control:
index_var: index
when: >
gluster_infra_thick_lvs is defined and (item.skipfs is not defined or not item.skipfs)
and lv_device_exists.results[index].stdout_lines is defined and "0" not in lv_device_exists.results[index].stdout_lines