diff --git a/Makefile.distros b/Makefile.distros index 6612ba52..248f4b79 100644 --- a/Makefile.distros +++ b/Makefile.distros @@ -4,7 +4,7 @@ DISTROS := alma8 alma9 \ debian10 debian11 debian12 \ devuan3 devuan4\ fedora37 fedora38 \ - freebsd13 \ + freebsd12 freebsd13 \ ol8 ol9 \ opensuse15 \ rocky8 rocky9 \ @@ -24,6 +24,7 @@ URL_devuan3 := https://files.devuan.org/devuan_beowulf/installer-iso/devua URL_devuan4 := https://files.devuan.org/devuan_chimaera/installer-iso/devuan_chimaera_4.0.0_amd64_server.iso URL_fedora37 := https://download.fedoraproject.org/pub/fedora/linux/releases/37/Cloud/x86_64/images/Fedora-Cloud-Base-37-1.7.x86_64.qcow2 URL_fedora38 := https://download.fedoraproject.org/pub/fedora/linux/releases/38/Cloud/x86_64/images/Fedora-Cloud-Base-38-1.6.x86_64.qcow2 +URL_freebsd12 := https://download.freebsd.org/ftp/releases/amd64/amd64/ISO-IMAGES/12.4/FreeBSD-12.4-RELEASE-amd64-disc1.iso URL_freebsd13 := https://download.freebsd.org/ftp/releases/amd64/amd64/ISO-IMAGES/13.2/FreeBSD-13.2-RELEASE-amd64-disc1.iso URL_ol8 := https://yum.oracle.com/templates/OracleLinux/OL8/u7/x86_64/OL8U7_x86_64-kvm-b148.qcow URL_ol9 := https://yum.oracle.com/templates/OracleLinux/OL9/u1/x86_64/OL9U1_x86_64-kvm-b158.qcow diff --git a/packer/freebsd12 b/packer/freebsd12 new file mode 120000 index 00000000..967d9b28 --- /dev/null +++ b/packer/freebsd12 @@ -0,0 +1 @@ +freebsd13 \ No newline at end of file diff --git a/packer/freebsd13/freebsd.sh b/packer/freebsd13/freebsd.sh index f1470b92..954105db 100644 --- a/packer/freebsd13/freebsd.sh +++ b/packer/freebsd13/freebsd.sh @@ -43,7 +43,7 @@ rm -rf /var/db/freebsd-update/* rm -rf /var/db/pkg/repo-FreeBSD.sqlite rm -rf /etc/ssh/ssh_host_* rm -rf /tmp/context -[ -s /etc/machine-id ] && rm -f /etc/machine-id +[ -s /etc/machine-id ] && rm -f /etc/machine-id || true # zero free space # dd if=/dev/zero of=/.zero bs=1m || : diff --git a/packer/freebsd13/freebsd12.pkr.hcl b/packer/freebsd13/freebsd12.pkr.hcl new file mode 100644 index 00000000..88247118 --- /dev/null +++ b/packer/freebsd13/freebsd12.pkr.hcl @@ -0,0 +1,128 @@ +variable "base_image" { + type = string +} + +variable "output_dir" { + type = string +} + +variable "appliance_name" { + type = string + default = "freebsd" +} + +variable "password" { + type = string + default = "opennebula" +} + +variable "http_dir" { + type = string +} + +variable "qemu_binary" { + type = string +} + + +source "qemu" "freebsd" { + boot_command = [ + "I", # Welcome: Install + "", # Keymap Selection: Continue with default + + "localhost", # Set hostname + "", + + "", # Distribution Select, OK + + "", # Partitioning Auto (UFS) + "E", # Entire Disk + "G", # GPT + "D", # Delete swap partition + "M", # Modify second partition + "rootfs", # Set rootfs label on root partition + "F", # Finish + "C", # Commit + + "", + + "opennebula", # Root password + "opennebula", + + "", # Network Configuration vtnet0 + "Y", # IPv4 yes + "Y", # DHCP yes + "N", # IPv6 no + "", # Resolver configuration + + "0", # Time Zone Selector: UTC + Time&Date + "Y", # Confirm + "S", # Skip date + "S", # Skip time + + "", # System Configuration, OK + + "", # System Hardening, OK + + "N", # Add User Accounts, no + + "E", # Final Configuration, Exit + + "Y", # Manual configuration, Yes + "sed -i '' -e 's/^#PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config", + "sed -i '' -e 's/^#PasswordAuthentication.*/PasswordAuthentication yes/' /etc/ssh/sshd_config", + "sed -i '' -e 's/^.*\\([[:space:]]\\/[[:space:]]\\)/\\/dev\\/gpt\\/rootfs\\1/' /etc/fstab", + "syncexit", + "R" # Complete: Reboot + ] + + boot_wait = "45s" + disk_cache = "unsafe" + disk_compression = true + disk_interface = "virtio" + disk_size = 4096 + format = "qcow2" + headless = false + + http_directory = "${var.http_dir}" + + iso_checksum = "none" + iso_url = "${var.base_image}" + + net_device = "virtio-net" + qemu_binary = "${var.qemu_binary}" + qemuargs = [ + ["-cpu", "host"], + ["-serial", "stdio"], + ] + ssh_password = "${var.password}" + ssh_port = 22 + ssh_username = "root" + ssh_wait_timeout = "10000s" + + shutdown_command = "poweroff" + + output_directory = "${var.output_dir}" + vm_name = "${var.appliance_name}" +} + +build { + sources = ["source.qemu.freebsd"] + + # Be carefull with shell inline provisioners, FreeBSD csh is tricky + + provisioner "shell" { + execute_command = "chmod +x {{ .Path }}; env {{ .Vars }} {{ .Path }}" + scripts = ["${var.http_dir}/mkdir.sh"] + } + + provisioner "file" { + destination = "/tmp/context" + source = "context-linux/out/" + } + + provisioner "shell" { + execute_command = "chmod +x {{ .Path }}; env {{ .Vars }} {{ .Path }}" + scripts = ["${var.http_dir}/freebsd.sh"] + } +} diff --git a/packer/freebsd13/freebsd.pkr.hcl b/packer/freebsd13/freebsd13.pkr.hcl similarity index 99% rename from packer/freebsd13/freebsd.pkr.hcl rename to packer/freebsd13/freebsd13.pkr.hcl index 34736661..05e67811 100644 --- a/packer/freebsd13/freebsd.pkr.hcl +++ b/packer/freebsd13/freebsd13.pkr.hcl @@ -75,7 +75,7 @@ source "qemu" "freebsd" { "R" # Complete: Reboot ] - boot_wait = "30s" + boot_wait = "45s" disk_cache = "unsafe" disk_compression = true disk_interface = "virtio" diff --git a/packer/freebsd13/run.sh b/packer/freebsd13/run.sh index 225fa5c0..6293e271 100755 --- a/packer/freebsd13/run.sh +++ b/packer/freebsd13/run.sh @@ -15,7 +15,7 @@ packer build -force \ -var "appliance_name=${DISTRO}" \ -var "http_dir=${DIR_CURR}" \ -var "output_dir=${PACKER_WORKING_DIR}" \ - "$DIR_CURR/freebsd.pkr.hcl" + "$DIR_CURR/$DISTRO.pkr.hcl" mv "$PACKER_WORKING_DIR/$DISTRO" "$DST"