Repository navigation
Expand file tree
/
Copy pathalmalinux-9-gencloud.pkr.hcl
More file actions
179 lines (173 loc) · 7.71 KB
/
Copy pathalmalinux-9-gencloud.pkr.hcl
File metadata and controls
179 lines (173 loc) · 7.71 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
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
# AlmaLinux OS 9 Packer template for Cloud-init included and OpenStack compatible Generic Cloud images
source "qemu" "almalinux-9-gencloud-x86_64" {
iso_url = local.iso_url_9_x86_64
iso_checksum = local.iso_checksum_9_x86_64
http_directory = var.http_directory
shutdown_command = var.root_shutdown_command
ssh_username = var.gencloud_ssh_username
ssh_password = var.gencloud_ssh_password
ssh_timeout = var.ssh_timeout
boot_command = var.gencloud_boot_command_9_x86_64
boot_wait = var.boot_wait
accelerator = "kvm"
disk_interface = "virtio-scsi"
disk_size = var.gencloud_disk_size
disk_cache = "unsafe"
disk_discard = "unmap"
disk_detect_zeroes = "unmap"
disk_compression = true
format = "qcow2"
headless = var.headless
machine_type = "q35"
memory = var.memory_x86_64
net_device = "virtio-net"
qemu_binary = var.qemu_binary
vm_name = "AlmaLinux-9-GenericCloud-${var.os_ver_9}-${formatdate("YYYYMMDD", timestamp())}.x86_64.qcow2"
cpu_model = "host"
cpus = var.cpus
efi_boot = true
efi_firmware_code = var.ovmf_code
efi_firmware_vars = var.ovmf_vars
efi_drop_efivars = true
}
source "qemu" "almalinux-9-gencloud-aarch64" {
iso_url = local.iso_url_9_aarch64
iso_checksum = local.iso_checksum_9_aarch64
http_directory = var.http_directory
shutdown_command = var.root_shutdown_command
ssh_username = var.gencloud_ssh_username
ssh_password = var.gencloud_ssh_password
ssh_timeout = var.ssh_timeout
boot_command = local.aarch64_gencloud_boot_command_9
boot_wait = var.boot_wait
accelerator = var.aarch64_accelerator
firmware = var.aavmf_code
use_pflash = false
disk_interface = "virtio-scsi"
disk_size = var.gencloud_disk_size
disk_cache = "unsafe"
disk_discard = "unmap"
disk_detect_zeroes = "unmap"
disk_compression = true
format = "qcow2"
headless = var.headless
machine_type = "virt,gic-version=max"
memory = var.memory_aarch64
net_device = "virtio-net"
qemu_binary = var.qemu_binary
vm_name = "AlmaLinux-9-GenericCloud-${var.os_ver_9}-${formatdate("YYYYMMDD", timestamp())}.aarch64.qcow2"
cpu_model = var.aarch64_cpu_model
cpus = var.cpus
qemuargs = concat(
[["-boot", "strict=on"], ["-monitor", "none"]],
# Tee the serial port into a log file instead of redirecting it: on the
# virt machine the firmware and GRUB console IS the serial port, shown
# on QEMU's VNC text console, and Packer types the boot command into it.
# "-serial file:" would take that input away (GRUB would never see the
# keys and boot its default media-check entry).
var.aarch64_console_log != "" ? [["-chardev", "vc,id=serial0,logfile=${var.aarch64_console_log}"], ["-serial", "chardev:serial0"]] : [],
)
}
source "qemu" "almalinux-9-gencloud-ppc64le" {
iso_url = local.iso_url_9_ppc64le
iso_checksum = local.iso_checksum_9_ppc64le
http_directory = var.http_directory
shutdown_command = var.root_shutdown_command
ssh_username = var.gencloud_ssh_username
ssh_password = var.gencloud_ssh_password
ssh_timeout = var.ssh_timeout
boot_command = local.gencloud_boot_command_9_ppc64le
boot_wait = var.gencloud_boot_wait_ppc64le
accelerator = var.ppc64le_accelerator
disk_interface = "virtio-scsi"
disk_size = var.gencloud_disk_size
disk_cache = "unsafe"
disk_discard = "unmap"
disk_detect_zeroes = "unmap"
disk_compression = true
format = "qcow2"
headless = var.headless
machine_type = var.ppc64le_machine_type
cpu_model = var.ppc64le_cpu_model
qemuargs = var.ppc64le_console_log != "" ? [["-serial", "file:${var.ppc64le_console_log}"]] : []
memory = var.memory_ppc64le
net_device = "virtio-net"
qemu_binary = var.qemu_binary
vm_name = "AlmaLinux-9-GenericCloud-${var.os_ver_9}-${formatdate("YYYYMMDD", timestamp())}.ppc64le.qcow2"
cpus = var.cpus
}
# s390x is built under TCG (full-system emulation) on the x86_64 runners:
# there are no s390x runners and KVM cannot accelerate a foreign arch, so
# a build takes hours rather than minutes. s390x has no BIOS boot menu to
# type a boot_command into, so the installer kernel and initrd are booted
# directly (-kernel/-initrd, downloaded by shared-steps into
# var.s390x_boot_dir) with inst.ks= on the kernel command line - the same
# direct-kernel install oz performs on the Jenkins s390x host. The s390x
# kickstart carries the whole provisioning in its %post (no Ansible: hence
# communicator "none" and the 'except' on the provisioner below) and ends
# with 'reboot'; -no-reboot turns that reboot into a QEMU exit, which is
# what a communicator-less build waits for (up to shutdown_timeout). The
# kernel line deliberately has NO cio_ignore=all,!condev (the ISO's
# generic.prm carries it for LPAR/z/VM installs): in a QEMU guest the
# virtio NIC and disk are CCW devices too and would be ignored, leaving the
# installer with no network to fetch the kickstart and no disk to install
# on - it then waits forever with an idle CPU. The
# target disk is a blank qcow2 pre-created by shared-steps and grown to
# disk_size (disk_image = true): no boot ISO is attached, because
# s390-ccw-virtio has no IDE bus for Packer's default CD-ROM. The SCLP
# console is written to var.s390x_boot_dir/console.log for diagnostics.
source "qemu" "almalinux-9-gencloud-s390x" {
iso_url = "${var.s390x_boot_dir}/blank.qcow2"
iso_checksum = "none"
disk_image = true
http_directory = var.http_directory
communicator = "none"
shutdown_timeout = var.s390x_install_timeout
boot_wait = "10s"
accelerator = "tcg"
disk_interface = "virtio"
disk_size = var.gencloud_disk_size
disk_cache = "unsafe"
disk_discard = "unmap"
disk_detect_zeroes = "unmap"
disk_compression = true
format = "qcow2"
headless = var.headless
machine_type = "s390-ccw-virtio"
memory = var.memory_s390x
net_device = "virtio-net"
qemu_binary = var.qemu_binary
vm_name = "AlmaLinux-9-GenericCloud-${var.os_ver_9}-${formatdate("YYYYMMDD", timestamp())}.s390x.qcow2"
cpus = var.cpus
qemuargs = [
["-cpu", "max"],
["-kernel", "${var.s390x_boot_dir}/kernel.img"],
["-initrd", "${var.s390x_boot_dir}/initrd.img"],
["-append", "ro ramdisk_size=40000 console=ttysclp0 ip=dhcp inst.text inst.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/almalinux-9.gencloud-s390x.ks"],
["-serial", "file:${var.s390x_boot_dir}/console.log"],
["-no-reboot"],
]
}
build {
sources = [
"source.qemu.almalinux-9-gencloud-x86_64",
"source.qemu.almalinux-9-gencloud-aarch64",
"source.qemu.almalinux-9-gencloud-ppc64le",
"source.qemu.almalinux-9-gencloud-s390x",
]
provisioner "ansible" {
galaxy_file = "./ansible/requirements.yml"
galaxy_force_install = true
collections_path = "./ansible/collections"
roles_path = "./ansible/roles"
playbook_file = "./ansible/gencloud.yml"
ansible_env_vars = [
"ANSIBLE_PIPELINING=True",
"ANSIBLE_REMOTE_TEMP=/tmp",
"ANSIBLE_SSH_TRANSFER_METHOD=scp",
"ANSIBLE_SCP_EXTRA_ARGS=-O",
]
# kickstart-only build, no SSH communicator (see the s390x source)
except = ["qemu.almalinux-9-gencloud-s390x"]
}
}