Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update #1559

Merged
merged 20 commits into from
Mar 20, 2024
Next Next commit
updates
Stromweld committed Feb 23, 2024
commit f529a258bb3ed86ef35f3b5b2450d47256798009
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ Bento is a project that encapsulates [Packer](https://www.packer.io/) templates

***NOTE:**

- Vagrant 2.4.0+ is required for new cpu archetecture support
- Vagrant 2.4.0+ is required for new cpu architecture support
- Virutalbox 6.x requires disabling nat config that allows vbox 7.x guests to connect to the host. To use comment out lines #161 and #162 in bento/packer_templates/pkr-variables.pkr.hcl or add variable `vboxmanage = []` to os_pkrvars files.
- When running packer build command the output directory is relative to the working directory the command is currently running in. Suggest running packer build commands from bento root directory for build working files to be placed in bento/builds/(build_name) directory by default. If the output_directory variable isn't overwritten a directory called builds/(build_name) will be created in the current working directory that you are running the command from

@@ -24,6 +24,14 @@ Vagrant.configure("2") do |config|
end
```

### Installing Bento

1. install ruby environment
2. clone repo
3. cd <path/to>/bento
4. gem build bento.gemspec
5. gem install bento-*.gem

### Building Boxes

#### Requirements
File renamed without changes.
67 changes: 67 additions & 0 deletions amazon_linux_2_hyperv_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/usr/bin/env bash

# Getting script directory location
SCRIPT_RELATIVE_DIR=$(dirname "${BASH_SOURCE[0]}")
cd "$SCRIPT_RELATIVE_DIR" || exit

# set tmp dir for files
AMZDIR="$(pwd)/packer_templates/amz_working_files"

# Get virtualbox vdi file name with latest version number
IMG="$(wget -q https://cdn.amazonlinux.com/os-images/latest/virtualbox/ -O - | grep ".vdi" | cut -d "\"" -f 2)"

# Download vbox vdi
echo "Downloading Vbox VDI $IMG"
wget -q -O "$AMZDIR"/amazon2.vdi -c https://cdn.amazonlinux.com/os-images/latest/virtualbox/"$IMG"

if [ ! -f "$AMZDIR"/amazon2.vdi ]; then
echo There must be a file named amazon2.vdi in "$AMZDIR"!
echo You can download the vdi file at https://cdn.amazonlinux.com/os-images/latest/virtualbox/
exit 1
fi

echo "Cleaning up old files"
rm -f "$AMZDIR"/*.iso "$AMZDIR"/*.ovf "$AMZDIR"/*.vmdk

echo "Creating ISO"
hdiutil makehybrid -o "$AMZDIR"/seed.iso -hfs -joliet -iso -default-volume-name cidata "$AMZDIR"/../amz_seed_iso

VM="AmazonLinuxBento"
echo Powering off and deleting any existing VMs named $VM
VBoxManage controlvm $VM poweroff --type headless 2> /dev/null
VBoxManage unregistervm $VM --delete 2> /dev/null
sleep 5

echo "Creating the VM"
# from https://www.perkin.org.uk/posts/create-virtualbox-vm-from-the-command-line.html
VBoxManage createvm --name $VM --ostype "RedHat_64" --register
VBoxManage storagectl $VM --name "SATA Controller" --add sata --controller IntelAHCI
VBoxManage storageattach $VM --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium "$AMZDIR"/amazon.vdi
VBoxManage storageattach $VM --storagectl "SATA Controller" --port 0 --device 1 --type dvddrive --medium "$AMZDIR"/seed.iso
VBoxManage modifyvm $VM --memory 2048
VBoxManage modifyvm $VM --cpus 2
VBoxManage modifyvm $VM --audio-driver none
VBoxManage modifyvm $VM --ioapic on
sleep 5

echo Sleeping for 120 seconds to let the system boot and cloud-init to run
VBoxManage startvm $VM --type headless
sleep 120
VBoxManage controlvm $VM poweroff --type headless
VBoxManage storageattach $VM --storagectl "SATA Controller" --port 0 --device 1 --type dvddrive --medium none
sleep 5

echo Exporting the VM to an OVF file
vboxmanage export $VM -o "$AMZDIR"/amazon2.ovf
sleep 5

echo Deleting the VM
vboxmanage unregistervm $VM --delete

echo starting packer build of amazonlinux
if packer build -timestamp-ui -only=virtualbox-ovf.amazonlinux -var-file="$AMZDIR"/../../os_pkrvars/amazonlinux/amazonlinux-2-x86_64.pkrvars.hcl "$AMZDIR"/../../packer_templates; then
echo "Cleaning up files"
rm -f "$AMZDIR"/*.ovf "$AMZDIR"/*.vmdk "$AMZDIR"/*.iso
else
exit 1
fi
67 changes: 67 additions & 0 deletions amazon_linux_2_parallels_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/usr/bin/env bash

# Getting script directory location
SCRIPT_RELATIVE_DIR=$(dirname "${BASH_SOURCE[0]}")
cd "$SCRIPT_RELATIVE_DIR" || exit

# set tmp dir for files
AMZDIR="$(pwd)/packer_templates/amz_working_files"

# Get virtualbox vdi file name with latest version number
IMG="$(wget -q https://cdn.amazonlinux.com/os-images/latest/virtualbox/ -O - | grep ".vdi" | cut -d "\"" -f 2)"

# Download vbox vdi
echo "Downloading Vbox VDI $IMG"
wget -q -O "$AMZDIR"/amazon2.vdi -c https://cdn.amazonlinux.com/os-images/latest/virtualbox/"$IMG"

if [ ! -f "$AMZDIR"/amazon2.vdi ]; then
echo There must be a file named amazon2.vdi in "$AMZDIR"!
echo You can download the vdi file at https://cdn.amazonlinux.com/os-images/latest/virtualbox/
exit 1
fi

echo "Cleaning up old files"
rm -f "$AMZDIR"/*.iso "$AMZDIR"/*.ovf "$AMZDIR"/*.vmdk

echo "Creating ISO"
hdiutil makehybrid -o "$AMZDIR"/seed.iso -hfs -joliet -iso -default-volume-name cidata "$AMZDIR"/../amz_seed_iso

VM="AmazonLinuxBento"
echo Powering off and deleting any existing VMs named $VM
VBoxManage controlvm $VM poweroff --type headless 2> /dev/null
VBoxManage unregistervm $VM --delete 2> /dev/null
sleep 5

echo "Creating the VM"
# from https://www.perkin.org.uk/posts/create-virtualbox-vm-from-the-command-line.html
VBoxManage createvm --name $VM --ostype "RedHat_64" --register
VBoxManage storagectl $VM --name "SATA Controller" --add sata --controller IntelAHCI
VBoxManage storageattach $VM --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium "$AMZDIR"/amazon.vdi
VBoxManage storageattach $VM --storagectl "SATA Controller" --port 0 --device 1 --type dvddrive --medium "$AMZDIR"/seed.iso
VBoxManage modifyvm $VM --memory 2048
VBoxManage modifyvm $VM --cpus 2
VBoxManage modifyvm $VM --audio-driver none
VBoxManage modifyvm $VM --ioapic on
sleep 5

echo Sleeping for 120 seconds to let the system boot and cloud-init to run
VBoxManage startvm $VM --type headless
sleep 120
VBoxManage controlvm $VM poweroff --type headless
VBoxManage storageattach $VM --storagectl "SATA Controller" --port 0 --device 1 --type dvddrive --medium none
sleep 5

echo Exporting the VM to an OVF file
vboxmanage export $VM -o "$AMZDIR"/amazon2.ovf
sleep 5

echo Deleting the VM
vboxmanage unregistervm $VM --delete

echo starting packer build of amazonlinux
if packer build -timestamp-ui -only=virtualbox-ovf.amazonlinux -var-file="$AMZDIR"/../../os_pkrvars/amazonlinux/amazonlinux-2-x86_64.pkrvars.hcl "$AMZDIR"/../../packer_templates; then
echo "Cleaning up files"
rm -f "$AMZDIR"/*.ovf "$AMZDIR"/*.vmdk "$AMZDIR"/*.iso
else
exit 1
fi
67 changes: 67 additions & 0 deletions amazon_linux_2_virtualbox_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/usr/bin/env bash

# Getting script directory location
SCRIPT_RELATIVE_DIR=$(dirname "${BASH_SOURCE[0]}")
cd "$SCRIPT_RELATIVE_DIR" || exit

# set tmp dir for files
AMZDIR="$(pwd)/packer_templates/amz_working_files"

# Get virtualbox vdi file name with latest version number
IMG="$(wget -q https://cdn.amazonlinux.com/os-images/latest/virtualbox/ -O - | grep ".vdi" | cut -d "\"" -f 2)"

# Download vbox vdi
echo "Downloading Vbox VDI $IMG"
wget -q -O "$AMZDIR"/amazon2.vdi -c https://cdn.amazonlinux.com/os-images/latest/virtualbox/"$IMG"

if [ ! -f "$AMZDIR"/amazon2.vdi ]; then
echo There must be a file named amazon2.vdi in "$AMZDIR"!
echo You can download the vdi file at https://cdn.amazonlinux.com/os-images/latest/virtualbox/
exit 1
fi

echo "Cleaning up old files"
rm -f "$AMZDIR"/*.iso "$AMZDIR"/*.ovf "$AMZDIR"/*.vmdk

echo "Creating ISO"
hdiutil makehybrid -o "$AMZDIR"/seed.iso -hfs -joliet -iso -default-volume-name cidata "$AMZDIR"/../amz_seed_iso

VM="AmazonLinuxBento"
echo Powering off and deleting any existing VMs named $VM
VBoxManage controlvm $VM poweroff --type headless 2> /dev/null
VBoxManage unregistervm $VM --delete 2> /dev/null
sleep 5

echo "Creating the VM"
# from https://www.perkin.org.uk/posts/create-virtualbox-vm-from-the-command-line.html
VBoxManage createvm --name $VM --ostype "RedHat_64" --register
VBoxManage storagectl $VM --name "SATA Controller" --add sata --controller IntelAHCI
VBoxManage storageattach $VM --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium "$AMZDIR"/amazon.vdi
VBoxManage storageattach $VM --storagectl "SATA Controller" --port 0 --device 1 --type dvddrive --medium "$AMZDIR"/seed.iso
VBoxManage modifyvm $VM --memory 2048
VBoxManage modifyvm $VM --cpus 2
VBoxManage modifyvm $VM --audio-driver none
VBoxManage modifyvm $VM --ioapic on
sleep 5

echo Sleeping for 120 seconds to let the system boot and cloud-init to run
VBoxManage startvm $VM --type headless
sleep 120
VBoxManage controlvm $VM poweroff --type headless
VBoxManage storageattach $VM --storagectl "SATA Controller" --port 0 --device 1 --type dvddrive --medium none
sleep 5

echo Exporting the VM to an OVF file
vboxmanage export $VM -o "$AMZDIR"/amazon2.ovf
sleep 5

echo Deleting the VM
vboxmanage unregistervm $VM --delete

echo starting packer build of amazonlinux
if packer build -timestamp-ui -only=virtualbox-ovf.amazonlinux -var-file="$AMZDIR"/../../os_pkrvars/amazonlinux/amazonlinux-2-x86_64.pkrvars.hcl "$AMZDIR"/../../packer_templates; then
echo "Cleaning up files"
rm -f "$AMZDIR"/*.ovf "$AMZDIR"/*.vmdk "$AMZDIR"/*.iso
else
exit 1
fi
67 changes: 67 additions & 0 deletions amazon_linux_2_vmware_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/usr/bin/env bash

# Getting script directory location
SCRIPT_RELATIVE_DIR=$(dirname "${BASH_SOURCE[0]}")
cd "$SCRIPT_RELATIVE_DIR" || exit

# set tmp dir for files
AMZDIR="$(pwd)/packer_templates/amz_working_files"

# Get virtualbox vdi file name with latest version number
IMG="$(wget -q https://cdn.amazonlinux.com/os-images/latest/virtualbox/ -O - | grep ".vdi" | cut -d "\"" -f 2)"

# Download vbox vdi
echo "Downloading Vbox VDI $IMG"
wget -q -O "$AMZDIR"/amazon2.vdi -c https://cdn.amazonlinux.com/os-images/latest/virtualbox/"$IMG"

if [ ! -f "$AMZDIR"/amazon2.vdi ]; then
echo There must be a file named amazon2.vdi in "$AMZDIR"!
echo You can download the vdi file at https://cdn.amazonlinux.com/os-images/latest/virtualbox/
exit 1
fi

echo "Cleaning up old files"
rm -f "$AMZDIR"/*.iso "$AMZDIR"/*.ovf "$AMZDIR"/*.vmdk

echo "Creating ISO"
hdiutil makehybrid -o "$AMZDIR"/seed.iso -hfs -joliet -iso -default-volume-name cidata "$AMZDIR"/../amz_seed_iso

VM="AmazonLinuxBento"
echo Powering off and deleting any existing VMs named $VM
VBoxManage controlvm $VM poweroff --type headless 2> /dev/null
VBoxManage unregistervm $VM --delete 2> /dev/null
sleep 5

echo "Creating the VM"
# from https://www.perkin.org.uk/posts/create-virtualbox-vm-from-the-command-line.html
VBoxManage createvm --name $VM --ostype "RedHat_64" --register
VBoxManage storagectl $VM --name "SATA Controller" --add sata --controller IntelAHCI
VBoxManage storageattach $VM --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium "$AMZDIR"/amazon.vdi
VBoxManage storageattach $VM --storagectl "SATA Controller" --port 0 --device 1 --type dvddrive --medium "$AMZDIR"/seed.iso
VBoxManage modifyvm $VM --memory 2048
VBoxManage modifyvm $VM --cpus 2
VBoxManage modifyvm $VM --audio-driver none
VBoxManage modifyvm $VM --ioapic on
sleep 5

echo Sleeping for 120 seconds to let the system boot and cloud-init to run
VBoxManage startvm $VM --type headless
sleep 120
VBoxManage controlvm $VM poweroff --type headless
VBoxManage storageattach $VM --storagectl "SATA Controller" --port 0 --device 1 --type dvddrive --medium none
sleep 5

echo Exporting the VM to an OVF file
vboxmanage export $VM -o "$AMZDIR"/amazon2.ovf
sleep 5

echo Deleting the VM
vboxmanage unregistervm $VM --delete

echo starting packer build of amazonlinux
if packer build -timestamp-ui -only=virtualbox-ovf.amazonlinux -var-file="$AMZDIR"/../../os_pkrvars/amazonlinux/amazonlinux-2-x86_64.pkrvars.hcl "$AMZDIR"/../../packer_templates; then
echo "Cleaning up files"
rm -f "$AMZDIR"/*.ovf "$AMZDIR"/*.vmdk "$AMZDIR"/*.iso
else
exit 1
fi
2 changes: 1 addition & 1 deletion lib/bento/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Bento
VERSION = '4.0.0'.freeze
VERSION = '4.0.1'.freeze
end
12 changes: 12 additions & 0 deletions os_pkrvars/amazonlinux/amazonlinux-2-aarch64-qemu.pkrvars.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
os_name = "amazonlinux"
os_version = "2"
os_arch = "aarch64"
iso_url = "https://cdn.amazonlinux.com/os-images/2.0.20240131.0/kvm-arm64/amzn2-kvm-2.0.20240131.0-arm64.xfs.gpt.qcow2"
iso_checksum = "file:https://cdn.amazonlinux.com/os-images/2.0.20240131.0/kvm-arm64/SHA256SUMS"
qemu_disk_image = true
sources_enabled = [
"source.qemu.vm"
]
parallels_guest_os_type = "centos"
vbox_guest_os_type = "RedHat_64"
vmware_guest_os_type = "arm-rhel9-64"
17 changes: 17 additions & 0 deletions os_pkrvars/amazonlinux/amazonlinux-2023-aarch64-qemu.pkrvars.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
os_name = "amazonlinux"
os_version = "2023"
os_arch = "aarch64"
iso_url = "https://cdn.amazonlinux.com/al2023/os-images/2023.3.20240131.0/kvm-arm64/al2023-kvm-2023.3.20240131.0-kernel-6.1-arm64.xfs.gpt.qcow2"
iso_checksum = "file:https://cdn.amazonlinux.com/al2023/os-images/2023.3.20240131.0/kvm-arm64/SHA256SUMS"
qemu_disk_image = true
cd_files = ["/Users/corey.hemminger/Documents/github/personal/chef/cookbooks/testing/bento/packer_templates/amz_seed_iso/*"]
qemu_efi_boot = true
qemu_efi_firmware_code = "/opt/homebrew/Cellar/qemu/8.2.1/share/qemu/edk2-arm-code.fd"
qemu_efi_firmware_vars = "/opt/homebrew/Cellar/qemu/8.2.1/share/qemu/edk2-arm-vars.fd"
qemu_efi_drop_efivars = null
sources_enabled = [
"source.qemu.vm"
]
parallels_guest_os_type = "centos"
vbox_guest_os_type = "RedHat_64"
vmware_guest_os_type = "arm-rhel9-64"
2 changes: 1 addition & 1 deletion os_pkrvars/ubuntu/ubuntu-22.04-aarch64.pkrvars.hcl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
os_name = "ubuntu"
os_version = "22.04"
os_arch = "aarch64"
iso_url = "https://cdimage.ubuntu.com/releases/jammy/release/ubuntu-22.04.3-live-server-arm64.iso"
iso_url = "https://cdimage.ubuntu.com/releases/jammy/release/ubuntu-22.04.4-live-server-arm64.iso"
iso_checksum = "file:https://cdimage.ubuntu.com/releases/jammy/release/SHA256SUMS"
parallels_guest_os_type = "ubuntu"
vbox_guest_os_type = "Ubuntu_64"
2 changes: 1 addition & 1 deletion os_pkrvars/ubuntu/ubuntu-22.04-x86_64.pkrvars.hcl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
os_name = "ubuntu"
os_version = "22.04"
os_arch = "x86_64"
iso_url = "https://releases.ubuntu.com/jammy/ubuntu-22.04.3-live-server-amd64.iso"
iso_url = "https://releases.ubuntu.com/jammy/ubuntu-22.04.4-live-server-amd64.iso"
iso_checksum = "file:https://releases.ubuntu.com/jammy/SHA256SUMS"
parallels_guest_os_type = "ubuntu"
vbox_guest_os_type = "Ubuntu_64"
17 changes: 12 additions & 5 deletions packer_templates/pkr-sources.pkr.hcl
Original file line number Diff line number Diff line change
@@ -174,11 +174,18 @@ source "parallels-iso" "vm" {
}
source "qemu" "vm" {
# QEMU specific options
accelerator = var.qemu_accelerator
display = var.headless ? "none" : var.qemu_display
machine_type = local.qemu_machine_type
qemu_binary = local.qemu_binary
qemuargs = local.qemuargs
accelerator = var.qemu_accelerator
display = var.headless ? "none" : var.qemu_display
disk_image = var.qemu_disk_image
efi_boot = var.qemu_efi_boot
efi_firmware_code = var.qemu_efi_firmware_code
efi_firmware_vars = var.qemu_efi_firmware_vars
efi_drop_efivars = var.qemu_efi_drop_efivars
format = var.qemu_format
machine_type = local.qemu_machine_type
qemu_binary = local.qemu_binary
qemuargs = local.qemuargs
skip_resize_disk = true
# Source block common options
boot_command = var.boot_command
boot_wait = var.qemu_boot_wait == null ? local.default_boot_wait : var.qemu_boot_wait
Loading