forked from projectatomic/atomic-host-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.yml
356 lines (275 loc) · 9.17 KB
/
main.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
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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
---
# vim: set ft=ansible:
#
# Core Functionality
# Verify rpms can installed and uninstalled after ostree admin unlock
# Verify overlayfs is created after running ostree admin unlock
# (use mount command verify presence of overlayfs mount)
# Verify ostree admin status indicates "Unlocked: development" after running
# ostree admin unlock
# Verify that changes to deployment after ostree admin unlock do not persist
# through reboot.
# Verify overlayfs is removed (use mount command verify absence of overlayfs
# mount)
# Verify ostree admin status does not show locked deployment
# Verify rpms can be installed and uninstalled after ostree admin unlock
# --hotfix and changes persist through reboot.
# Verify ostree admin status indicates "Unlocked: hotfix"
# Verify a clone of the current deployment is added to the deployment
# Use rpm-ostree status to verify there are two deployments with the same
# commit ID
# Verify overlayfs is created (use mount command verify presence of overlayfs
# mount)
# Verify rpms can still be installed and uninstalled after reboot
# Verify ostree admin unlock --hotfix overwrites any other deployment already
# on the system
# Verify rollback between hotfixed deployment and regular deployment
# NOT TESTED:
# Verify upgrade from hotfixed deployment
# Upgrade should be successful
# Packages installed in previous unlocked deployment should not be present
# in the upgraded deployment
#
# Negative Testing
# Verify rpms cannot be installed without ostree admin unlock
# Run ostree admin unlock twice. Verify that an error message specifying
# that the deployment is already in an unlocked state: development
# Run ostree admin unlock, then ostree admin unlock --hotfix. Verify that
# an error message specifying that the deployment is already in an unlocked
# state: development
# Run ostree admin unlock --hotfix twice. Verify that an error message
# specifying that the deployment is already in an unlocked state: hotfix
# Run ostree admin unlock --hotfix then ostree admin unlock. Verify that an
# error message specifying that the deployment is already in an unlocked
# state: hotfix
- name: Ostree Admin Unlock - Setup
hosts: all
become: yes
tags:
- setup
vars_files:
- vars.yml
pre_tasks:
- name: Verify all
fail:
msg: "Required variables are not defined. Check vars.yml file."
when: g_rpm_url is undefined or
g_rpm_name is undefined or
g_rpm_name_2 is undefined
roles:
# This playbook requires Ansible 2.2 and an Atomic Host
- role: ansible_version_check
avc_major: "2"
avc_minor: "2"
tags:
- ansible_version_check
# Subscribe if the system is RHEL
- role: redhat_subscription
when: ansible_distribution == 'RedHat'
tags:
- redhat_subscription
- name: Ostree Admin Unlock - Add/Remove Package - Non-persistence
hosts: all
become: yes
tags:
- unlock_add_remove_package_non_persistence
vars_files:
- vars.yml
roles:
- role: ostree_admin_unlock
- role: overlayfs_verify_present
- role: rpm_install
rpm_url: "{{ g_rpm_url }}"
- role: package_verify_present
rpm_name: "{{ g_rpm_name }}"
check_binary: false
- role: rpm_uninstall
rpm_name: "{{ g_rpm_name }}"
- role: package_verify_missing
rpm_name: "{{ g_rpm_name }}"
- role: rpm_install
rpm_url: "{{ g_rpm_url }}"
tags:
- second_install
- role: package_verify_present
rpm_name: "{{ g_rpm_name }}"
check_binary: false
tags:
- second_verify_present
- role: reboot
- role: overlayfs_verify_missing
- role: package_verify_missing
rpm_name: "{{ g_rpm_name }}"
tags:
- second_verify_missing
- name: Ostree Admin Unlock - Hotfix - Add/Remove Package Persistence
hosts: all
become: yes
tags:
- hotfix_add_remove_package_persistence
vars_files:
- vars.yml
roles:
- role: ostree_admin_unlock_hotfix
- role: overlayfs_verify_present
- role: rpm_install
rpm_url: "{{ g_rpm_url }}"
- role: package_verify_present
rpm_name: "{{ g_rpm_name }}"
check_binary: false
- role: rpm_uninstall
rpm_name: "{{ g_rpm_name }}"
- role: package_verify_missing
rpm_name: "{{ g_rpm_name }}"
- role: rpm_install
rpm_url: "{{ g_rpm_url }}"
tags:
- second_install
- role: package_verify_present
rpm_name: "{{ g_rpm_name }}"
check_binary: false
tags:
- second_verify_present
- role: reboot
- role: overlayfs_verify_present
- role: package_verify_present
rpm_name: "{{ g_rpm_name }}"
check_binary: false
tags:
- third_verify_present
- role: epel_rpm_url
rpm_name: "{{ g_rpm_name_2 }}"
- role: rpm_install
rpm_url: "{{ epel_rpm_url }}"
tags:
- third_install
- role: package_verify_present
rpm_name: "{{ g_rpm_name_2 }}"
tags:
- fourth_verify_present
- name: Ostree Admin Unlock - Hotfix - Rollback
hosts: all
become: yes
tags:
- hotfix_rollback
vars_files:
- vars.yml
roles:
- role: rpm_ostree_rollback
- role: reboot
- role: overlayfs_verify_missing
- role: package_verify_missing
rpm_name: "{{ g_rpm_name }}"
- role: package_verify_missing
rpm_name: "{{ g_rpm_name_2 }}"
tags:
- second_package_verify_missing
- name: Ostree Admin Unlock - No Install Without Unlock
hosts: all
become: yes
tags:
- cannot_install_without_unlock
vars_files:
- vars.yml
tasks:
- name: Attempt to install rpm
command: rpm -i {{ g_rpm_url }}
register: attempted_install
failed_when: attempted_install.rc != 1
- include_role:
name: rpm_ostree_status
- name: Fail if current deployment has unlocked not set to none
fail:
msg: "Booted deployment does not have 'unlocked' not set to none"
when: "'none' not in ros_booted['unlocked']"
- name: Ostree Admin Unlock - Unlock Twice - Error Message
hosts: all
become: yes
tags:
- unlock_twice_error_message
vars_files:
- vars.yml
tasks:
- name: Unlock system
command: ostree admin unlock
- include_role:
name: rpm_ostree_status
- name: Verify rpm_ostree status is unlocked and set to hotfix
fail:
msg: "Booted deployment does not have 'unlocked' set to hotfix"
when: "'development' not in ros_booted['unlocked']"
- name: Run unlock twice (system is already unlocked)
command: ostree admin unlock
register: double_unlock
failed_when: double_unlock.rc != 1
- name: Fail when error message is incorrect
fail:
msg: "Error message is incorrect"
when: "'Deployment is already in unlocked state: development' not in double_unlock.stderr"
- name: Run unlock hotfix (system is already locked)
command: ostree admin unlock --hotfix
register: double_hotfix_unlock
failed_when: double_hotfix_unlock.rc != 1
- name: Fail when error message is incorrect
fail:
msg: "Error message is incorrect"
when: "'Deployment is already in unlocked state: development' not in double_unlock.stderr"
- include_role:
name: reboot
- name: Ostree Admin Unlock - Hotfix Unlock Twice - Error Message
hosts: all
become: yes
tags:
- hotfix_unlock_twice_error_message
vars_files:
- vars.yml
tasks:
- name: Unlock system with hotfix
command: ostree admin unlock --hotfix
- include_role:
name: rpm_ostree_status
- name: Verify rpm_ostree status has unlocked set to hotfix
fail:
msg: "Booted deployment is not unlocked and set to hotfix"
when: "'hotfix' not in ros_booted['unlocked']"
- name: Fail if non booted deployment does not have same commit id as booted
fail:
msg: "Deployments have different commit_IDs"
when: ros_not_booted['checksum'] != ros_booted['checksum']
- name: Run unlock twice (system is already unlocked)
command: ostree admin unlock
register: double_unlock
failed_when: double_unlock.rc != 1
- name: Fail when error message is incorrect
fail:
msg: "Error message is incorrect"
when: "'Deployment is already in unlocked state: hotfix' not in double_unlock.stderr"
- name: Run unlock hotfix (system is already locked)
command: ostree admin unlock --hotfix
register: double_hotfix_unlock
failed_when: double_hotfix_unlock.rc != 1
- name: Fail when error message is incorrect
fail:
msg: "Error message is incorrect"
when: "'Deployment is already in unlocked state: hotfix' not in double_unlock.stderr"
- name: Ostree Admin Unlock - Cleanup
hosts: all
become: yes
tags:
- cleanup
vars_files:
- vars.yml
roles:
- role: rpm_ostree_rollback
tags:
- rpm_ostree_rollback
- role: reboot
tags:
- reboot
- role: rpm_ostree_cleanup_all
tags:
- rpm_ostree_cleanup_all
- role: redhat_unsubscribe
when: ansible_distribution == 'RedHat'
tags:
- redhat_unsubscribe