-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path05_create_vm.yaml
More file actions
73 lines (69 loc) · 2.2 KB
/
05_create_vm.yaml
File metadata and controls
73 lines (69 loc) · 2.2 KB
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
---
- name: Create RHEL 9 VM on OpenShift Virtualization
hosts: localhost
connection: local
gather_facts: false
vars:
kubeconfig_path: "/root/ocp4/auth/kubeconfig"
namespace: "rhce-consulting-vms"
vm_name: "rhel9-1"
tasks:
- name: Ensure required Python packages are installed
pip:
name:
- openshift
- kubernetes
state: present
- name: Create a VirtualMachine custom resource
k8s:
kubeconfig: "{{ kubeconfig_path }}"
state: present
definition:
apiVersion: kubevirt.io/v1
kind: VirtualMachine
metadata:
name: "{{ vm_name }}"
namespace: "{{ namespace }}"
spec:
running: true
template:
metadata:
labels:
kubevirt.io/domain: "{{ vm_name }}"
spec:
domain:
devices:
disks:
- name: containerdisk
disk:
bus: virtio
- name: cloudinitdisk
disk:
bus: virtio
interfaces:
- name: localnet-nad
bridge: {}
resources:
requests:
memory: 4Gi
networks:
- multus:
networkName: default/localnet-nad
name: localnet-nad
volumes:
- name: containerdisk
containerDisk:
image: registry.redhat.io/rhel9/rhel-guest-image:latest
- cloudInitNoCloud:
userData: |
#cloud-config
users:
- name: rhel
groups: users
shell: /bin/bash
lock_passwd: false
passwd: "encrypted_pass"
chpasswd:
expire: false
ssh_pwauth: true
name: cloudinitdisk