-
Notifications
You must be signed in to change notification settings - Fork 1
/
proxmox_create_vm_template_20_04_gluster_cloudinit.sls
87 lines (66 loc) · 1.91 KB
/
proxmox_create_vm_template_20_04_gluster_cloudinit.sls
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
# get ubuntu 20.04 cloud image
{% if opts.id == 'p20' %}
{% set vm_template_id = '9005' %}
{% elif opts.id == 'p21' %}
{% set vm_template_id = '9006' %}
{% endif %}
{% set release_name = "focal" %}
{% set image_name = "ubuntu-20.04-server-cloudimg-amd64.img" %}
{% set gluster_volume = "gv1" %}
get_ubuntu_18_04:
cmd.run:
- name: |
curl -L https://cloud-images.ubuntu.com/releases/{{release_name}}/release/{{image_name}} -o /var/lib/vz/template/iso/{{image_name}}
- shell: /bin/bash
- timeout: 300
- creates: /var/lib/vz/template/iso/{{image_name}}
create_instance:
cmd.run:
- name: |
qm create {{ vm_template_id }} -name ubuntu-cloudinit-{{ vm_template_id }} -memory 1024 -net0 virtio,bridge=lxdbr0 -cores 1 -sockets 1
import_image:
cmd.run:
- name: |
qm importdisk {{ vm_template_id }} /var/lib/vz/template/iso/{{image_name}} {{gluster_volume}}
attach_disk:
cmd.run:
- name: |
qm set {{ vm_template_id }} -scsihw virtio-scsi-pci -virtio0 {{gluster_volume}}:vm-{{ vm_template_id }}-disk-0
attach_serial:
cmd.run:
- name: |
qm set {{ vm_template_id }} -serial0 socket
set_bootdisk:
cmd.run:
- name: |
qm set {{ vm_template_id }} -boot c -bootdisk virtio0
set_qemu_agent:
cmd.run:
- name: |
qm set {{ vm_template_id }} -agent 1
set_hotplug:
cmd.run:
- name: |
qm set {{ vm_template_id }} -hotplug disk,network,usb
set_cpus:
cmd.run:
- name: |
qm set {{ vm_template_id }} -vcpus 1
add_vga:
cmd.run:
- name: |
qm set {{ vm_template_id }} -vga qxl
set_cloudinit_drive:
cmd.run:
- name: |
qm set {{ vm_template_id }} -ide2 {{gluster_volume}}:cloudinit
# 8GB
resize_drive:
cmd.run:
- name: |
qm resize {{ vm_template_id }} virtio0 8G
# Convert the VM to the template
template_convert:
cmd.run:
- name: |
qm template {{ vm_template_id }}