-
Notifications
You must be signed in to change notification settings - Fork 0
/
checks-syntax.yaml
220 lines (197 loc) · 7.63 KB
/
checks-syntax.yaml
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
---
# tasks file for btrfssubvol
- name: "Check public role variable syntax"
ansible.builtin.assert:
that:
# btrfssubvol_device_uuid is none or is a string
- btrfssubvol_device_uuid is defined
- >
(btrfssubvol_device_uuid is none) or
(btrfssubvol_device_uuid is string)
- >
(btrfssubvol_device_uuid is none) or
(btrfssubvol_device_uuid | length > 0)
- >
(btrfssubvol_device_uuid is none) or
(btrfssubvol_device_uuid is ansible.builtin.match("^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$"))
# btrfssubvol_mount_parent is a string
- btrfssubvol_mount_parent is defined
- btrfssubvol_mount_parent is not none
- btrfssubvol_mount_parent is string
- btrfssubvol_mount_parent | length > 0
- btrfssubvol_mount_parent[0] == "/"
# btrfssubvol_mount_options is a list
- btrfssubvol_mount_options is defined
- btrfssubvol_mount_options is not none
- btrfssubvol_mount_options is not string
- btrfssubvol_mount_options is not mapping
- btrfssubvol_mount_options is iterable
# btrfssubvol_subvolumes is a list
- btrfssubvol_subvolumes is defined
- btrfssubvol_subvolumes is not none
- btrfssubvol_subvolumes is not string
- btrfssubvol_subvolumes is not mapping
- btrfssubvol_subvolumes is iterable
# btrfssubvol_unmount_ignore_errors is a boolean
- btrfssubvol_unmount_ignore_errors is defined
- btrfssubvol_unmount_ignore_errors is not none
- btrfssubvol_unmount_ignore_errors is boolean
# btrfssubvol_unmount_unmanaged_mounts is a boolean
- btrfssubvol_unmount_unmanaged_mounts is defined
- btrfssubvol_unmount_unmanaged_mounts is not none
- btrfssubvol_unmount_unmanaged_mounts is boolean
fail_msg: Public role variable have bad syntax. Check your configuration.
success_msg: Syntax correct for public role variables.
quiet: true
tags:
- checks
- checks-syntax
- name: "Include checks for btrfssubvol_mount_options"
ansible.builtin.include_tasks:
file: checks-syntax-var-mount-options.yaml
tags:
- checks
- checks-syntax
vars:
mount_options: "{{ btrfssubvol_mount_options }}"
label_for_check: "'btrfssubvol_mount_options'"
- name: "Check btrfssubvol_subvolumes syntax"
ansible.builtin.assert:
that:
# subvolume.name is a string
- subvolume.name is defined
- subvolume.name is not none
- subvolume.name is string
- subvolume.name | length > 0
# subvolume.device_uuid is not defined or is a string
- >
(subvolume.device_uuid is not defined) or
(subvolume.device_uuid is not none)
- >
(subvolume.device_uuid is not defined) or
(subvolume.device_uuid is string)
- >
(subvolume.device_uuid is not defined) or
(subvolume.device_uuid | length > 0)
- >
(subvolume.device_uuid is not defined) or
(subvolume.device_uuid is ansible.builtin.match("^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$"))
# Either btrfssubvol_device_uuid or subvolume.device_uuid need to be a UUID.
# The previous checks already ensure correct UUID syntax, so a comparison
# that one is a string is sufficient.
- (btrfssubvol_device_uuid is string) or (subvolume.device_uuid is string)
# subvolume.owner is not defined or is a string
- >
(subvolume.owner is not defined) or
(subvolume.owner is not none)
- >
(subvolume.owner is not defined) or
(subvolume.owner is string)
- >
(subvolume.owner is not defined) or
(subvolume.owner | length > 0)
# subvolume.group is not defined or is a string
- >
(subvolume.group is not defined) or
(subvolume.group is not none)
- >
(subvolume.group is not defined) or
(subvolume.group is string)
- >
(subvolume.group is not defined) or
(subvolume.group | length > 0)
# subvolume.mount_options is not defined or is a list
- >
(subvolume.mount_options is not defined) or
(subvolume.mount_options is not none)
- >
(subvolume.mount_options is not defined) or
(subvolume.mount_options is not string)
- >
(subvolume.mount_options is not defined) or
(subvolume.mount_options is not mapping)
- >
(subvolume.mount_options is not defined) or
(subvolume.mount_options is iterable)
# subvolume.mount_point is not defined or is a string
- >
(subvolume.mount_point is not defined) or
(subvolume.mount_point is not none)
- >
(subvolume.mount_point is not defined) or
(subvolume.mount_point is string)
- >
(subvolume.mount_point is not defined) or
(subvolume.mount_point | length == 0) or
(subvolume.mount_point[0] == "/")
# subvolume.mount_state is not defined or is a string
- >
(subvolume.mount_state is not defined) or
(subvolume.mount_state is not none)
- >
(subvolume.mount_state is not defined) or
(subvolume.mount_state is string)
- >
(subvolume.mount_state is not defined) or
(subvolume.mount_state | length > 0)
- >
(subvolume.mount_state is not defined) or
(subvolume.mount_state in ["absent", "absent_from_fstab", "mounted", "present", "unmounted", "remounted", "ephemeral"])
# subvolume.recurse is not defined or is a boolean
- >
(subvolume.recurse is not defined) or
(subvolume.recurse is not none)
- >
(subvolume.recurse is not defined) or
(subvolume.recurse is boolean)
# subvolume.unmount_ignore_errors is not defined or is a boolean
- >
(subvolume.unmount_ignore_errors is not defined) or
(subvolume.unmount_ignore_errors is not none)
- >
(subvolume.unmount_ignore_errors is not defined) or
(subvolume.unmount_ignore_errors is boolean)
# subvolume.unmount_unmanaged_mounts is not defined or is a boolean
- >
(subvolume.unmount_unmanaged_mounts is not defined) or
(subvolume.unmount_unmanaged_mounts is not none)
- >
(subvolume.unmount_unmanaged_mounts is not defined) or
(subvolume.unmount_unmanaged_mounts is boolean)
fail_msg: |
Item syntax of 'btrfssubvol_subvolumes' is faulty. Ensure your list items
have following syntax:
- name (string, mandatory)
- owner (string, optional)
- device_uuid (string, optional): Required if btrfssubvol_device_uuid is not set.
- group (string, optional)
- mount_options (list / elements=string, optional)
- mount_state (string, optional)
- recurse (boolean, optional)
- unmount_ignore_errors (boolean, optional)
- unmount_unmanaged_mounts (boolean, optional)
Consult the documentation for further information on the values.
success_msg: All items in 'btrfssubvol_subvolumes' have correct syntax.
quiet: true
loop: "{{ btrfssubvol_subvolumes }}"
loop_control:
loop_var: subvolume
tags:
- checks
- checks-syntax
- name: "Include checks for mount_options per btrfssubvol_subvolumes item"
ansible.builtin.include_tasks:
file: checks-syntax-var-mount-options.yaml
loop: "{{ btrfssubvol_subvolumes }}"
loop_control:
loop_var: subvolume
label: "{{ subvolume.name }}"
tags:
- checks
- checks-syntax
vars:
mount_options: "{{ subvolume.mount_options }}"
label_for_check: "subvolume '{{ subvolume.name }}'"
when:
- subvolume.mount_options is defined
# End of file