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

Support Rocky 9 and refactor to be distro agnostic #35

Merged
merged 1 commit into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions packer/distro-vars/rocky9-aarch64.pkrvars.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# We are using Rocky 9 here as RHEL release < 9 won't boot on M Series Macbooks
source_image_url="https://dl.rockylinux.org/pub/rocky/9.4/images/aarch64/Rocky-9-GenericCloud-Base-9.4-20240509.0.aarch64.qcow2"
source_image_checksum="4475b93bc0c0808697774ea7f77a465052d7d5259266618a3153eecf1780b6a3"
31 changes: 19 additions & 12 deletions packer/hashibox.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,26 @@ variable "consul_cni_version" {
description = "Consul CNI version to install"
}

variable "fedora_iso_url" {
variable "source_image_url" {
type = string
default = "https://download.fedoraproject.org/pub/fedora/linux/releases/40/Cloud/aarch64/images/Fedora-Cloud-Base-Generic.aarch64-40-1.14.qcow2"
description = "Fedora Cloud Image URL - qcow2 format"
}

variable "fedora_iso_checksum" {
variable "source_image_checksum" {
type = string
default = "file:https://download.fedoraproject.org/pub/fedora/linux/releases/40/Cloud/aarch64/images/Fedora-Cloud-40-1.14-aarch64-CHECKSUM"
description = "Checksum in the packer format of the cloud image"
}

source "qemu" "hashibox" {
iso_url = "${var.fedora_iso_url}"
iso_checksum = "${var.fedora_iso_checksum}"
iso_url = "${var.source_image_url}"
iso_checksum = "${var.source_image_checksum}"

headless = true

disk_compression = true
disk_size = "5G"
# disk_size = "5G"
disk_interface = "virtio"
disk_image = true

Expand Down Expand Up @@ -75,9 +75,9 @@ source "qemu" "hashibox" {
]

communicator = "ssh"
shutdown_command = "echo fedora | sudo -S shutdown -P now"
ssh_password = "fedora"
ssh_username = "fedora"
shutdown_command = "echo shikari | sudo -S shutdown -P now"
ssh_password = "shikari"
ssh_username = "shikari"

ssh_timeout = "10m"
}
Expand All @@ -95,16 +95,23 @@ build {
"sudo dnf clean all",
"sudo dnf install -y unzip wget",

# For multicast DNS to use with socket_vmnet in Lima
"sudo dnf install -y crudini",
# For multicast DNS to use with socket_vmnet in Lima we use systemd-resolved. For rocky we have to install epel repo for Crudini.
"source /etc/os-release && [[ $ID != fedora ]] && sudo dnf install -y epel-release systemd-resolved && sudo systemctl enable --now systemd-resolved",
"sudo dnf install -y crudini $([ $(source /etc/os-release && echo $ID) != fedora ] && echo --enablerepo=epel)",
"sudo mkdir /etc/systemd/resolved.conf.d/ && sudo crudini --ini-options=nospace --set /etc/systemd/resolved.conf.d/mdns.conf Resolve MulticastDNS yes",

# With systemd-resolved enabled, we should use the stub-resolver for mDNS to work.
"sudo rm /etc/resolv.conf && sudo ln -s /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf",

"sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo",
# Enable Docker repository and install Docker-CE
"sudo dnf config-manager --add-repo https://download.docker.com/linux/$([ $(source /etc/os-release && echo $ID) == fedora ] && echo fedora || echo rhel)/docker-ce.repo",
"sudo dnf install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin",

"sudo dnf config-manager --add-repo https://rpm.releases.hashicorp.com/fedora/hashicorp.repo",
# Enable HashiCorp Repository and install the required packages including CNI libs
"sudo dnf config-manager --add-repo https://rpm.releases.hashicorp.com/$([ $(source /etc/os-release && echo $ID) == fedora ] && echo fedora || echo RHEL)/hashicorp.repo",
"sudo dnf install -y consul-$CONSUL_VERSION* nomad-$NOMAD_VERSION* containernetworking-plugins",

# Nomad expects CNI binaries to be under /opt/cni/bin by default. We use symlink to avoid configuring alternate path in Nomad.
"sudo mkdir /opt/cni && sudo ln -s /usr/libexec/cni /opt/cni/bin",

# Consul CNI Binary, required for Nomad Transparent Proxy Support.
Expand Down
Binary file modified packer/userdata/cidata.iso
Binary file not shown.
4 changes: 2 additions & 2 deletions packer/userdata/user-data
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

system_info:
default_user:
name: fedora
name: shikari

chpasswd:
list: |
fedora:fedora
shikari:shikari
expire: False
ssh_pwauth: True
resize_rootfs: True