Skip to content

Commit cdd0597

Browse files
committed
Add CentOS, AlmaLinux packer images
1 parent 843595b commit cdd0597

File tree

12 files changed

+205
-0
lines changed

12 files changed

+205
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Build and Push AlmaLinux cloud diskimage
2+
3+
on:
4+
push:
5+
branches:
6+
- "main"
7+
schedule:
8+
- cron: "0 0 */2 * *"
9+
workflow_dispatch:
10+
11+
12+
jobs:
13+
build-diskimage-almalinux-packer:
14+
uses: ./.github/workflows/reusable-build-diskimage-packer.yml
15+
with:
16+
container_name: almalinux-cloud
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Build and Push CentOS cloud diskimage
2+
3+
on:
4+
push:
5+
branches:
6+
- "main"
7+
schedule:
8+
- cron: "0 0 */2 * *"
9+
workflow_dispatch:
10+
11+
12+
jobs:
13+
build-diskimage-centos-packer:
14+
uses: ./.github/workflows/reusable-build-diskimage-packer.yml
15+
with:
16+
container_name: centos-cloud
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
FROM scratch
2+
ADD ./output-almalinux/packer-almalinux /disk.qcow2
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../.devcontainer/almalinux/Containerfile
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#cloud-config
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#cloud-config
2+
system_info:
3+
default_user:
4+
name: ""
5+
6+
chpasswd:
7+
list: |
8+
root:password
9+
expire: false
10+
11+
ssh_pwauth: true
12+
13+
network:
14+
version: 2
15+
ethernets:
16+
"*":
17+
dhcp4: true
18+
19+
runcmd:
20+
- echo "PermitRootLogin yes" > /etc/ssh/sshd_config.d/00-packer.conf
21+
- echo "PasswordAuthentication yes" >> /etc/ssh/sshd_config.d/00-packer.conf
22+
- systemctl restart sshd
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
packer {
2+
required_plugins {
3+
qemu = {
4+
version = ">= 1.0.0"
5+
source = "github.com/hashicorp/qemu"
6+
}
7+
}
8+
}
9+
10+
source "qemu" "almalinux" {
11+
accelerator = "kvm"
12+
disk_image = true
13+
iso_url = "https://repo.almalinux.org/almalinux/9/cloud/x86_64/images/AlmaLinux-9-GenericCloud-9.6-20250522.x86_64.qcow2"
14+
iso_checksum = "sha256:b08cd5db79bf32860412f5837e8c7b8df9447e032376e3c622840b31aaf26bc6"
15+
output_directory = "output-almalinux"
16+
format = "qcow2"
17+
memory = 2048
18+
disk_size = "20480"
19+
ssh_username = "root"
20+
ssh_password = "password"
21+
ssh_wait_timeout = "30m"
22+
net_device = "virtio-net"
23+
headless = true
24+
25+
cd_files = [".packer/almalinux-cloud/cloud-init/user-data", ".packer/almalinux-cloud/cloud-init/meta-data"]
26+
cd_label = "CIDATA"
27+
28+
shutdown_command = "shutdown -P now"
29+
shutdown_timeout = "1m"
30+
31+
qemuargs = [["-serial", "stdio"], ["-cpu", "host"]]
32+
}
33+
34+
build {
35+
name = "almalinux"
36+
sources = ["source.qemu.almalinux"]
37+
38+
provisioner "shell-local" {
39+
script = ".packer/machinefile.sh"
40+
environment_vars = [
41+
"TARGET=almalinux-cloud",
42+
"USER_PASSWD=password",
43+
"SSH_HOST=${build.Host}",
44+
"SSH_PORT=${build.Port}"]
45+
}
46+
47+
# disable cloud-init
48+
provisioner "shell" {
49+
inline = [
50+
"touch /etc/cloud/cloud-init.disabled"
51+
]
52+
}
53+
54+
# disable root and password login
55+
provisioner "shell" {
56+
inline = [
57+
"rm -f /etc/ssh/sshd_config.d/00-packer.conf"
58+
]
59+
}
60+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
FROM scratch
2+
ADD ./output-centos/packer-centos /disk.qcow2

.packer/centos-cloud/Machinefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../.devcontainer/centos/Containerfile
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#cloud-config

0 commit comments

Comments
 (0)