Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
1a724d9
refactor: remove directories and modify `centos-9` packer config
dbrennand Feb 8, 2023
5f1c65f
refactor: rename file
dbrennand Feb 8, 2023
fae11ad
fix: undefined variable issue
dbrennand Feb 9, 2023
b0ee554
fix: add missing `url` and `repo`
dbrennand Feb 9, 2023
e756de7
fix: reboot when install has finished and install wget
dbrennand Feb 9, 2023
79206bd
fix: increase disk to ~40GB
dbrennand Feb 9, 2023
0675fec
refactor: remove drag as centos default FS is xfs
dbrennand Feb 9, 2023
99274d5
feat: https://developer.hashicorp.com/vagrant/docs/boxes/base#ssh-tweaks
dbrennand Feb 9, 2023
a1d6a5a
refactor: update script
dbrennand Feb 9, 2023
8d39c56
refactor: modify default `vm_name`
dbrennand Feb 9, 2023
ca05a4f
feat: add working vagrant file
dbrennand Feb 9, 2023
673c31c
feat: add box to vagrant
dbrennand Feb 9, 2023
42002cc
refactor: remove files
dbrennand Feb 9, 2023
cb52ae1
docs(refactor): add prerequisites and usage
dbrennand Feb 9, 2023
246dd22
docs(refactor): remove number
dbrennand Feb 9, 2023
ac87e50
refactor: hardcode username and password
dbrennand Feb 9, 2023
62a4904
feat: add artifacts
dbrennand Feb 13, 2023
f41845a
feat: ubuntu 22.04
dbrennand Feb 13, 2023
4b8f742
refactor: https://kb.vmware.com/s/article/89983?lang=en_US
dbrennand Feb 13, 2023
582dc92
refactor: update image URL
dbrennand Apr 9, 2023
54e1396
refactor: remove blacklist
dbrennand Apr 9, 2023
3c9b732
fix: boot stuck at network
dbrennand Apr 9, 2023
f20ba28
fix: command sequence
dbrennand Apr 9, 2023
15654a0
fix: add missing `-`
dbrennand Apr 9, 2023
73fcec3
feat: add `v.gui`
dbrennand Apr 9, 2023
d1cb39f
fix: correct home permissions
dbrennand Apr 9, 2023
67a5771
chore: ignore `.vagrant`
dbrennand Apr 9, 2023
774de51
refactor: changes
dbrennand Apr 9, 2023
449f6bc
refactor: fix permissions for /home/vagrant
dbrennand Apr 9, 2023
6436d5e
ignore `.box`
dbrennand Apr 9, 2023
4d302b0
docs(refactor): support ubuntu 22.04
dbrennand Apr 9, 2023
9d269de
refactor: comment
dbrennand Apr 9, 2023
dad46e6
docs(refactor): VMware
dbrennand Apr 9, 2023
c3f264c
docs(refactor): usage
dbrennand Apr 9, 2023
2f7b904
feat: add `debian-11`
dbrennand Apr 16, 2023
7f63806
fix: HGFS setup
dbrennand Apr 16, 2023
d4ba958
docs(refactor): add debian 11
dbrennand Apr 16, 2023
bbe7166
fix: add missing package `fuse`
dbrennand Apr 18, 2023
961c0ea
docs(refactor): VMware Fusion link for registering for personal license
dbrennand Apr 18, 2023
49cfe0b
docs(refactor): specifically VMware Fusion
dbrennand Apr 18, 2023
d9ca79b
refactor: add quotes
dbrennand Aug 2, 2023
6494bfd
fix: iso URLs
dbrennand Aug 2, 2023
be32560
chore: update license year
dbrennand Aug 2, 2023
ac791fe
docs: add LICENSE
dbrennand Aug 2, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
output
.DS_Store
packer_cache
packer_cache
artifacts
.vagrant
*.box
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2022 Adam Hartley
Copyright (c) 2023 Adam Hartley

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
76 changes: 52 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,64 @@
# arm-base-boxes
Vagrant Base Boxes for ARM Hosts (e.g., Apple Silicon / M1)

This repository provides the Packer files for building Vagrant base boxes for ARM hosts.
VMware Fusion Vagrant base boxes for ARM hosts (e.g., Apple Silicon M1).

The pre-built boxes can be found on [Vagrant Cloud](https://app.vagrantup.com/bytesguy)
This repository contains Packer files for building VMware Fusion based Vagrant base boxes for ARM hosts.

🚨 These should not be used for production workloads - use them at your own risk! 🚨
🚨 These Vagrant boxes should not be used for production workloads - use them at your own risk! 🚨

## Currently Supported Boxes
## Supported Boxes

| Distro | Version | Provider | Source | Box |
| ------ | ------- | -------- | ------ | --- |
| Ubuntu Server | 20.04.3 (Focal Fossa) | VMWare Fusion | [Source](ubuntu-server-20.04/) | [bytesguy/ubuntu-server-20.04-arm64](https://app.vagrantup.com/bytesguy/boxes/ubuntu-server-20.04-arm64) |
| Ubuntu Server | 20.04.3 (Focal Fossa) | Parallels | [Source](ubuntu-server-20.04/) | [bytesguy/ubuntu-server-20.04-arm64](https://app.vagrantup.com/bytesguy/boxes/ubuntu-server-20.04-arm64) |
| Ubuntu Server | 21.10 (Impish Indri) | VMWare Fusion | [Source](ubuntu-server-21.10/) | [bytesguy/ubuntu-server-21.10-arm64](https://app.vagrantup.com/bytesguy/boxes/ubuntu-server-21.10-arm64) |
| Debian | 11.2 (Bullseye) | VMWare Fusion | [Source](debian-11/) | [bytesguy/debian-11-arm64](https://app.vagrantup.com/bytesguy/boxes/debian-11-arm64) |
| Debian | 11.3 (Bullseye) | Parallels | [Source](debian-11/) | [bytesguy/debian-11-arm64](https://app.vagrantup.com/bytesguy/boxes/debian-11-arm64) |
| Debian | 10.11 (Buster) | VMWare Fusion | [Source](debian-10/) | [bytesguy/debian-10-arm64](https://app.vagrantup.com/bytesguy/boxes/debian-10-arm64) |
| Distro | Version | Provider | Source |
| ------------- | ------- | ------------- | ----------------------------- |
| CentOS Stream | 9 | VMware Fusion | [Source](centos-9) |
| Ubuntu Server | 22.04.2 | VMware Fusion | [Source](ubuntu-server-22.04) |
| Debian | 11 | VMware Fusion | [Source](debian-11) |

## In-Progress / Planned
## Dependencies

| Distro | Version | Provider | Source |
| ------ | ------- | -------- | ------ |
| Ubuntu Server | 22.04 | VMWare Fusion | [Source](ubuntu-server-22.04/) |
| Centos | 9 Stream | VMWare Fusion | [Source](centos-9/) |
| Fedora | 35 | VMWare Fusion | [Source](fedora-35/) |
| FreeBSD | 14 | VMWare Fusion | [Source](freebsd-14/) |
- [Packer](https://www.packer.io/):

## Usage Instructions
```bash
brew install packer
```

TODO
- [Vagrant](https://www.vagrantup.com/):

## Building Instructions
```bash
# You may need to install rosetta first
# sudo softwareupdate --install-rosetta
brew install --cask vagrant
```

The VM images are built with Packer and VMWare Fusion. Each subdirectory in this repo contains all the files needed to build the base box. The easiest way of building the box is to run the `buildbox.sh` command. This will start Packer and build the image, then compact the image into a box and print the checksum.
- [VMware Fusion](https://customerconnect.vmware.com/en/evalcenter?p=fusion-player-personal-13)
- [Vagrant VMware Utility](https://formulae.brew.sh/cask/vagrant-vmware-utility):

```bash
brew install --cask vagrant-vmware-utility
```

- [Vagrant VMware provider plugin](https://developer.hashicorp.com/vagrant/docs/providers/vmware/installation):

```bash
vagrant plugin install vagrant-vmware-desktop
```

## Usage

1. Use the `buildbox.sh` script in each directory to build the box and add it to Vagrant:

```bash
chmod +x ./buildbox.sh && ./buildbox.sh
```

2. Start the VM with Vagrant:

```bash
vagrant up
```

Enjoy! ✨🚀

## License

[MIT](LICENSE)
11 changes: 11 additions & 0 deletions centos-9/Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
config.vm.box = "centos9-arm64"
config.vm.provider "vmware_desktop" do |v|
v.gui = true
v.vmx["ethernet0.virtualDev"] = "e1000e"
v.vmx["usb_xhci.present"] = "true"
end
end
6 changes: 0 additions & 6 deletions centos-9/add-key.sh

This file was deleted.

22 changes: 14 additions & 8 deletions centos-9/buildbox.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
#!/bin/bash
BOX_NAME="centos9-arm64.box"

# TODO: Pull and inject md5 hash into packer
packer init vmware-centos9.pkr.hcl
packer build -force vmware-centos9.pkr.hcl
cp metadata.json output/metadata.json
cd output
tar cvzf vmware-centos9-arm64.box ./*
md5 vmware-centos9-arm64.box
rm -f *.v* *.nvram metadata.json
# Initalise packer and build the VM
packer init .
packer build -force .
# Copy Vagrant metadata file to artifacts directory
cp metadata.json artifacts/metadata.json && cd artifacts
# Create Vagrant box
tar -cvzf $BOX_NAME ./*
# Show the SHA256 checksum of the box
shasum -a 256 $BOX_NAME
# Clean up
rm -f *.v* *.nvram *.log *.scoreboard *.plist metadata.json
# Add the box to Vagrant
vagrant box add --force --name "centos9-arm64" $BOX_NAME
106 changes: 106 additions & 0 deletions centos-9/centos9.auto.pkr.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
// centos9 packer variables file

variable "vm_guest_os_language" {
type = string
description = "Guest OS language"
default = "en_GB"
}

variable "vm_guest_os_keyboard" {
type = string
description = "Guest OS keyboard"
default = "gb"
}

variable "vm_guest_os_timezone" {
type = string
description = "Guest OS timezone"
default = "Europe/London"
}

variable "vm_guest_os_install_url" {
type = string
description = "Guest OS install URL"
default = "https://mirror.stream.centos.org/9-stream/BaseOS/aarch64/os/"
}

variable "vm_guest_os_repo_url" {
type = string
description = "Guest OS repo URL"
default = "https://mirror.stream.centos.org/9-stream/AppStream/aarch64/os/"
}

// https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#disk_size
variable "disk_size" {
type = number
description = "Size of the disk in MB"
// ~40GB
default = 40000
}

// https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#guest_os_type
variable "guest_os_type" {
type = string
description = "Guest OS type"
default = "arm-fedora-64"
}

// https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#version
variable "vmx_hardware_version" {
type = number
description = "VMX hardware version"
default = 20
}

// https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#vm_name
variable "vm_name" {
type = string
description = "VM name"
default = "centos9"
}

// https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#extra-disk-configuration
variable "disk_adapter_type" {
type = string
description = "Disk adapter type"
default = "nvme"
}

// https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#extra-disk-configuration
variable "disk_type_id" {
type = string
description = "Disk type ID"
default = "1"
}

// https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#iso-configuration
variable "iso_checksum" {
type = string
description = "ISO checksum"
default = "file:https://mirror.stream.centos.org/9-stream/BaseOS/aarch64/iso/CentOS-Stream-9-latest-aarch64-boot.iso.SHA256SUM"
}

variable "iso_url" {
type = string
default = "https://mirror.stream.centos.org/9-stream/BaseOS/aarch64/iso/CentOS-Stream-9-latest-aarch64-boot.iso"
}

// https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#hardware-configuration
variable "cpus" {
type = number
description = "Number of CPUs"
default = 2
}

variable "memory" {
type = number
description = "Memory in MB"
default = 2048
}

// https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#optional-ssh-fields
variable "ssh_timeout" {
type = string
description = "SSH timeout"
default = "30m"
}
91 changes: 91 additions & 0 deletions centos-9/centos9.pkr.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
packer {
required_version = ">= 1.8.5"
required_plugins {
vmware = {
version = ">= 1.0.7"
source = "github.com/hashicorp/vmware"
}
}
}

locals {
data_source_content = {
"/ks.cfg" = templatefile("${abspath(path.root)}/data/ks.pkrtpl.hcl", {
vm_guest_os_language = var.vm_guest_os_language
vm_guest_os_keyboard = var.vm_guest_os_keyboard
vm_guest_os_timezone = var.vm_guest_os_timezone
vm_guest_os_install_url = var.vm_guest_os_install_url
vm_guest_os_repo_url = var.vm_guest_os_repo_url
})
}
}

source "vmware-iso" "centos-9" {
// Optional configuration
// https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#optional
disk_size = var.disk_size
guest_os_type = var.guest_os_type
version = var.vmx_hardware_version
vm_name = var.vm_name

// Extra disk configuration
// https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#extra-disk-configuration
disk_adapter_type = var.disk_adapter_type
disk_type_id = var.disk_type_id

// ISO configuration
// https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#iso-configuration
iso_checksum = var.iso_checksum
iso_url = var.iso_url

// HTTP configuration
// https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#http-directory-configuration
http_content = local.data_source_content

// Shutdown configuration
// https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#shutdown-configuration
shutdown_command = "sudo shutdown -h now"

// Hardware configuration
// https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#hardware-configuration
cpus = var.cpus
memory = var.memory
usb = true

// Output configuration
// https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#output-configuration
output_directory = "artifacts"

// VMX configuration
// https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#vmx-configuration
vmx_data = {
"ethernet0.virtualdev" = "e1000e"
"usb_xhci.present" = "true"
}

// SSH configuration
// https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#optional-ssh-fields
ssh_username = "vagrant"
ssh_password = "vagrant"
ssh_timeout = var.ssh_timeout

// Boot configuration
// https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#boot-configuration
boot_command = [
"<up>",
"e",
"<down><down><end><wait>",
"<spacebar>text inst.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg",
"<enter><wait><leftCtrlOn>x<leftCtrlOff>"
]
}

build {
sources = ["sources.vmware-iso.centos-9"]

provisioner "shell" {
scripts = [
"scripts/post-install.sh"
]
}
}
45 changes: 45 additions & 0 deletions centos-9/data/ks.pkrtpl.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Kickstart file for CentOS 9 Stream
reboot
text --non-interactive
eula --agreed

# Configure language
lang ${vm_guest_os_language}

# Configure keyboard
keyboard ${vm_guest_os_keyboard}

# Configure timezone
timezone ${vm_guest_os_timezone}

# Configure install source
url --url=${vm_guest_os_install_url}

# Configure repo for CentOS 9 Stream
repo --name=centos9-AppStream --baseurl=${vm_guest_os_repo_url}

# Configure packages to be installed
%packages
@^minimal-environment
open-vm-tools
wget
%end

# Run the setup agent on first boot
firstboot --enable

# Configure disk and paritioning
ignoredisk --only-use=nvme0n1
autopart

# Partition clearing information
clearpart --none --initlabel

# Root password and user configuration
rootpw --plaintext vagrant
user --groups=wheel --name=vagrant --password=vagrant --plaintext --uid=1000 --gid=1000 --gecos="vagrant"

# Post configuration
%post
echo 'vagrant ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/vagrant
%end
Loading