-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexercise7-break.yaml
51 lines (46 loc) · 1.5 KB
/
exercise7-break.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
---
- name: Preparing the exercise7
hosts: localhost
gather_facts: true
vars:
user: "{{ lookup('env', 'USER') }}"
tasks:
- name: Creating the exercise7 virtual machine
kubernetes.core.k8s:
state: present
template: "exercise7-vm.yaml.j2"
register: breakvm
until: breakvm is succeeded
retries: 60
delay: 10
failed_when: breakvm is failed or breakvm.failed
- name: Wait for VM to be running
kubernetes.core.k8s_info:
api_version: kubevirt.io/v1
kind: VirtualMachineInstance
namespace: "namespace-{{ user }}"
name: "exercise7"
register: exercise7info
until: "exercise7info.resources | length > 0 and exercise7info.resources[0].status.phase == 'Running'"
retries: 60
delay: 10
failed_when: exercise7info.resources | length == 0
- name: Create the VM snapshot
kubernetes.core.k8s:
kind: VirtualMachineSnapshot
namespace: 'namespace-{{ user }}'
definition:
apiVersion: snapshot.kubevirt.io/v1alpha1
kind: VirtualMachineSnapshot
metadata:
name: exercise7-snapshot
spec:
source:
apiGroup: kubevirt.io
kind: VirtualMachine
name: exercise7
- name: Create exercise7-restoresnapshot.yaml script
ansible.builtin.template:
src: 'exercise7-restoresnapshot.yaml.j2'
dest: '/home/{{ user }}/exercise7-restoresnapshot.yaml'
mode: '0644'