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

Debian 12 packer template and some minor fixes #3

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
83 changes: 83 additions & 0 deletions example_build/deb12k6.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
{
"variables": {
"ssh_user": "patient0",
"ssh_password": "packer"
},
"sensitive-variables": ["ssh_password"],
"builders": [
{
"name": "10_generator",
"type": "file",
"content": "#cloud-config\nssh_pwauth: True\nusers:\n - name: {{user `ssh_user`}}\n plain_text_passwd: {{user `ssh_password`}}\n sudo: ALL=(ALL) NOPASSWD:ALL\n groups: users, sudo\n shell: /bin/bash\n lock_passwd: false\n",
"target": "httpdir/user-data"
},
{
"name": "20_builder",
"type": "qemu",
"iso_url": "https://cdimage.debian.org/cdimage/cloud/bookworm/latest/debian-12-generic-amd64.qcow2",
"iso_checksum": "file:https://cdimage.debian.org/cdimage/cloud/bookworm/latest/SHA512SUMS",
"disk_image": true,
"disk_size": "3G",
"disk_compression": true,
"format": "qcow2",
"headless": "true",
"boot_wait": -1,
"communicator": "ssh",
"ssh_username": "{{user `ssh_user`}}",
"ssh_clear_authorized_keys": true,
"ssh_password": "{{user `ssh_password`}}",
"temporary_key_pair_type": "ed25519",
"shutdown_command": "echo '{{user `ssh_password`}}' | sudo -S su root -c \"userdel -rf {{user `ssh_user`}}; rm /etc/sudoers.d/90-cloud-init-users; shutdown -P now\"",
"output_directory": "output",
"vm_name": "deb12k6.qcow2",
"qemuargs": [
[
"-serial",
"stdio"
],
[
"-m",
"512"
],
[
"-cdrom",
"cidata.iso"
]
]
}
],
"provisioners": [
{
"type": "shell-local",
"inline_shebang": "/bin/bash -xe",
"inline": "cd httpdir && genisoimage -output ../cidata.iso -input-charset utf-8 -volid cidata -joliet -r user-data meta-data",
"only": [
"10_generator"
]
},
{
"script": "scripts/pre-install-baremetal.sh",
"type": "shell",
"execute_command": "chmod +x {{ .Path }} && sudo {{ .Path }}",
"only": [
"20_builder"
]
},
{
"only": [
"20_builder"
],
"type": "file",
"source": "files/make_image_bootable.sh",
"destination": "/tmp/make_image_bootable.sh"
},
{
"only": [
"20_builder"
],
"type": "shell",
"inline": "sudo -S mkdir /root/.ovh/ && sudo -S mv /tmp/make_image_bootable.sh /root/.ovh/ && sudo -S chmod -R +x /root/.ovh/",
"pause_before": "5s"
}
]
}
15 changes: 10 additions & 5 deletions example_build/scripts/pre-install-baremetal.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,21 @@ apt-get -y purge grub-cloud-amd64
# grub-pc or grub-efi-amd64's postinst.
cp /usr/share/grub/default/grub /etc/default/grub

apt-get update

# Add contrib to allow ZFS installation
# Add non-free-firmware for AMD and Intel microcodes
sed -i "s/\bmain\b/& contrib non-free/" /etc/apt/sources.list
apt-get -y install --no-install-recommends lsb-release
if [ $(lsb_release -rs 2>/dev/null) -ge 12 ];
then
sed -i "s/\bmain\b/& contrib non-free-firmware/" /etc/apt/sources.list.d/debian.sources
else
sed -i "s/\bmain\b/& contrib non-free/" /etc/apt/sources.list
fi

apt-get update

kernel=$(apt-cache search linux-image-6 | grep -vE 'rt|cloud|unsigned|headers|dbg' | awk '{ print $1 }')

apt-get -y install --no-install-recommends "${kernel}"
apt-get -y install --no-install-recommends linux-image-amd64

apt-get -y install --no-install-recommends mdadm lvm2 patch btrfs-progs amd64-microcode intel-microcode
# We will install these in make_image_bootable.sh and only when ZFS is used
Expand All @@ -36,7 +42,6 @@ echo "grub-efi-amd64 grub2/update_nvram boolean false" | debconf-set-selections

# Cleanup
apt-get -y autoremove
apt-get -y clean
apt-get -y autoclean

# Disable some cloud-init options:
Expand Down