Skip to content

Commit

Permalink
add freebsd12
Browse files Browse the repository at this point in the history
  • Loading branch information
xorel committed Oct 24, 2023
1 parent bc2e371 commit 56413bf
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 4 deletions.
3 changes: 2 additions & 1 deletion Makefile.distros
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ DISTROS := alma8 alma9 \
debian10 debian11 debian12 \
devuan3 devuan4\
fedora37 fedora38 \
freebsd13 \
freebsd12 freebsd13 \
ol8 ol9 \
opensuse15 \
rocky8 rocky9 \
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions packer/freebsd12
2 changes: 1 addition & 1 deletion packer/freebsd13/freebsd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 || :
Expand Down
128 changes: 128 additions & 0 deletions packer/freebsd13/freebsd12.pkr.hcl
Original file line number Diff line number Diff line change
@@ -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<wait>", # Welcome: Install
"<enter><wait>", # Keymap Selection: Continue with default

"localhost", # Set hostname
"<enter><wait>",

"<enter><wait>", # Distribution Select, OK

"<enter><wait>", # Partitioning Auto (UFS)
"E<wait>", # Entire Disk
"G<enter><wait>", # GPT
"<down><down><down>D<wait>", # Delete swap partition
"M<wait>", # Modify second partition
"<tab><tab><down><down>rootfs<enter><wait>", # Set rootfs label on root partition
"F<wait>", # Finish
"C<wait>", # Commit

"<wait2m30s>",

"opennebula<enter><wait>", # Root password
"opennebula<enter><wait>",

"<enter><wait>", # Network Configuration vtnet0
"Y<wait>", # IPv4 yes
"Y<wait10>", # DHCP yes
"N<wait>", # IPv6 no
"<enter><wait>", # Resolver configuration

"0<enter><wait>", # Time Zone Selector: UTC + Time&Date
"Y<wait>", # Confirm
"S<wait>", # Skip date
"S<wait>", # Skip time

"<enter><wait>", # System Configuration, OK

"<enter><wait>", # System Hardening, OK

"N<wait>", # Add User Accounts, no

"E<enter><wait10>", # Final Configuration, Exit

"Y<wait>", # Manual configuration, Yes
"sed -i '' -e 's/^#PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config<enter><wait>",
"sed -i '' -e 's/^#PasswordAuthentication.*/PasswordAuthentication yes/' /etc/ssh/sshd_config<enter><wait>",
"sed -i '' -e 's/^.*\\([[:space:]]\\/[[:space:]]\\)/\\/dev\\/gpt\\/rootfs\\1/' /etc/fstab<enter><wait>",
"sync<enter>exit<enter><wait>",
"R<wait10>" # 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"]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ source "qemu" "freebsd" {
"R<wait10>" # Complete: Reboot
]

boot_wait = "30s"
boot_wait = "45s"
disk_cache = "unsafe"
disk_compression = true
disk_interface = "virtio"
Expand Down
2 changes: 1 addition & 1 deletion packer/freebsd13/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 56413bf

Please sign in to comment.