commit 7ca85131e8cf59938d653de8450756005bdfdcff
parent 90d04970495c5a6c09d5cc204b626d1be35b28d8
Author: Andreas Gruhler <andreas.gruhler@adfinis.com>
Date: Fri, 12 May 2023 15:39:02 +0200
feat: add centos9 example
Diffstat:
3 files changed, 86 insertions(+), 0 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -1,2 +1,3 @@
vars.json
output*
+manifest.json
diff --git a/config/ks-9.cfg b/config/ks-9.cfg
@@ -0,0 +1,46 @@
+#version=RHEL9
+#ignoredisk --only-use=sda
+clearpart --none --initlabel
+autopart --type=lvm
+
+cmdline
+
+# Use network installation
+repo --name="AppStream" --baseurl="https://mirror.stream.centos.org/9-stream/AppStream/x86_64/os/"
+url --url="https://mirror.stream.centos.org/9-stream/BaseOS/x86_64/os"
+
+# Keyboard layouts
+keyboard --vckeymap=us --xlayouts='us'
+# System language
+lang en_US.UTF-8
+# System timezone
+timezone Europe/Zurich --isUtc
+
+# Network information
+network --bootproto=dhcp --device=link --ipv6=auto --activate
+network --hostname=localhost.localdomain
+
+# Root password
+rootpw root
+
+# Do not configure the X Window System
+skipx
+# System services
+services --enabled=sshd,chronyd
+firewall --enabled --service=ssh
+
+reboot
+
+%packages
+@core
+@^minimal install
+qemu-guest-agent
+%end
+
+# Once the installation is complete,
+# but before the system is rebooted for the first time
+%post
+# enable the password-based SSH root logins
+echo "PermitRootLogin yes" > /etc/ssh/sshd_config.d/01-permitrootlogin.conf
+%end
+
diff --git a/libvirt-centos9.pkr.hcl b/libvirt-centos9.pkr.hcl
@@ -0,0 +1,39 @@
+
+variable "manifest" {
+ type = string
+ default = "manifest.json"
+}
+
+source "qemu" "centos9" {
+ accelerator = "kvm"
+ boot_command = ["<up><tab> rd.shell ip=dhcp inst.cmdline inst.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks-9.cfg<enter>"]
+ boot_wait = "5s"
+ cpu_model = "host"
+ disk_interface = "virtio"
+ disk_size = "14000"
+ memory = "4096"
+ net_device = "virtio-net"
+ format = "qcow2"
+ http_directory = "config"
+ iso_checksum = "file:https://linuxsoft.cern.ch/centos-stream/9-stream/BaseOS/x86_64/iso/CentOS-Stream-9-latest-x86_64-boot.iso.SHA256SUM"
+ iso_url = "https://linuxsoft.cern.ch/centos-stream/9-stream/BaseOS/x86_64/iso/CentOS-Stream-9-latest-x86_64-boot.iso"
+ shutdown_command = "echo 'packer' | sudo -S shutdown -P now"
+ ssh_timeout = "20m"
+ ssh_username = "root"
+ ssh_password = "root"
+ vm_name = "centos9-${formatdate("YYYYMMDD-hhmmss", timestamp())}"
+ output_directory = "centos9-${formatdate("YYYYMMDD-hhmmss", timestamp())}"
+}
+
+build {
+ sources = ["source.qemu.centos9"]
+
+ provisioner "shell" {
+ script = "scripts/cloud-config.sh"
+ }
+
+ post-processor "manifest" {
+ output = "${var.manifest}"
+ strip_path = true
+ }
+}