Add qemu builder
This commit adds support for QEMU
This commit is contained in:
parent
5b4dd18d7c
commit
c7ee084eb8
5 changed files with 232 additions and 52 deletions
8
.gitignore
vendored
8
.gitignore
vendored
|
@ -1,5 +1,7 @@
|
|||
/packer_cache/
|
||||
/babelbox/
|
||||
/build/
|
||||
*.iso
|
||||
.*.swp
|
||||
/babelbox-qemu/
|
||||
/babelbox-virtualbox/
|
||||
/babelbox/
|
||||
/build/
|
||||
/packer_cache/
|
||||
|
|
|
@ -1,51 +1,119 @@
|
|||
{
|
||||
"description": "Debian Babelbox",
|
||||
"builders": [{
|
||||
"boot_command": [
|
||||
"<esc><wait>",
|
||||
"install <wait>",
|
||||
"preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg ",
|
||||
"debian-installer/locale=en_US <wait>",
|
||||
"auto <wait>",
|
||||
"netcfg/get_hostname={{ .Name }} <wait>",
|
||||
"netcfg/get_domain=demo.local <wait>",
|
||||
"fb=false <wait>",
|
||||
"debconf/frontend=noninteractive <wait>",
|
||||
"console-setup/ask_detect=false <wait>",
|
||||
"console-keymaps-at/keymap=de <wait>",
|
||||
"keyboard-configuration/xkb-keymap=de <wait>",
|
||||
"<enter><wait>"
|
||||
],
|
||||
"disk_size": 10240,
|
||||
"guest_os_type": "Debian_64",
|
||||
"hard_drive_interface": "sata",
|
||||
"headless": false,
|
||||
"http_directory": "http",
|
||||
"iso_checksum": "6a901b5abe43d88b39d627e1339d15507cc38f980036b928f835e0f0e957d3d8",
|
||||
"iso_checksum_type": "sha256",
|
||||
"iso_url": "https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-10.3.0-amd64-netinst.iso",
|
||||
"shutdown_command": "sudo /sbin/halt -p",
|
||||
"ssh_username": "demo",
|
||||
"ssh_password": "babelbox",
|
||||
"ssh_port": "22",
|
||||
"ssh_wait_timeout": "1800s",
|
||||
"type": "virtualbox-iso",
|
||||
"vm_name": "babelbox-buster",
|
||||
"vboxmanage": [
|
||||
["modifyvm", "{{.Name}}", "--memory", "1024"],
|
||||
["modifyvm", "{{.Name}}", "--cpus", "1"]
|
||||
],
|
||||
"output_directory": "babelbox"
|
||||
}],
|
||||
"provisioners": [{
|
||||
"type": "shell",
|
||||
"execute_command": "{{ .Vars }} sudo -E /bin/sh '{{ .Path }}'",
|
||||
"scripts": [
|
||||
"scripts/babelbox-partitions.sh",
|
||||
"scripts/setup-babelbox.sh",
|
||||
"scripts/virtualbox.sh",
|
||||
"scripts/cleanup.sh",
|
||||
"scripts/minimize.sh"
|
||||
]
|
||||
}]
|
||||
"builders": [
|
||||
{
|
||||
"type": "virtualbox-iso",
|
||||
"boot_command": [
|
||||
"<esc><wait>",
|
||||
"install <wait>",
|
||||
"preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg ",
|
||||
"debian-installer/locale=en_US <wait>",
|
||||
"auto <wait>",
|
||||
"netcfg/get_hostname={{ .Name }} <wait>",
|
||||
"netcfg/get_domain=demo.local <wait>",
|
||||
"fb=false <wait>",
|
||||
"debconf/frontend=noninteractive <wait>",
|
||||
"console-setup/ask_detect=false <wait>",
|
||||
"console-keymaps-at/keymap=de <wait>",
|
||||
"keyboard-configuration/xkb-keymap=de <wait>",
|
||||
"<enter><wait>"
|
||||
],
|
||||
"disk_size": 10240,
|
||||
"guest_os_type": "Debian_64",
|
||||
"hard_drive_interface": "sata",
|
||||
"headless": false,
|
||||
"http_directory": "http",
|
||||
"iso_checksum": "6a901b5abe43d88b39d627e1339d15507cc38f980036b928f835e0f0e957d3d8",
|
||||
"iso_checksum_type": "sha256",
|
||||
"iso_url": "https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-10.3.0-amd64-netinst.iso",
|
||||
"shutdown_command": "sudo systemctl poweroff",
|
||||
"ssh_username": "demo",
|
||||
"ssh_password": "babelbox",
|
||||
"ssh_port": "22",
|
||||
"ssh_wait_timeout": "1800s",
|
||||
"vm_name": "babelbox-buster",
|
||||
"vboxmanage": [
|
||||
[
|
||||
"modifyvm",
|
||||
"{{.Name}}",
|
||||
"--memory",
|
||||
"1024"
|
||||
],
|
||||
[
|
||||
"modifyvm",
|
||||
"{{.Name}}",
|
||||
"--cpus",
|
||||
"1"
|
||||
]
|
||||
],
|
||||
"output_directory": "babelbox-virtualbox"
|
||||
},
|
||||
{
|
||||
"type": "qemu",
|
||||
"iso_checksum": "6a901b5abe43d88b39d627e1339d15507cc38f980036b928f835e0f0e957d3d8",
|
||||
"iso_checksum_type": "sha256",
|
||||
"iso_url": "https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-10.3.0-amd64-netinst.iso",
|
||||
"output_directory": "babelbox-qemu",
|
||||
"shutdown_command": "sudo systemctl poweroff",
|
||||
"disk_size": "10240M",
|
||||
"format": "qcow2",
|
||||
"accelerator": "kvm",
|
||||
"http_directory": "http-qemu",
|
||||
"ssh_username": "demo",
|
||||
"ssh_password": "babelbox",
|
||||
"ssh_timeout": "20m",
|
||||
"vm_name": "babelbox-buster",
|
||||
"net_device": "virtio-net",
|
||||
"disk_interface": "virtio",
|
||||
"disk_detect_zeroes": "on",
|
||||
"boot_wait": "10s",
|
||||
"boot_command": [
|
||||
"<esc><wait>",
|
||||
"install <wait>",
|
||||
"preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg ",
|
||||
"debian-installer/locale=en_US <wait>",
|
||||
"auto <wait>",
|
||||
"netcfg/get_hostname={{ .Name }} <wait>",
|
||||
"netcfg/get_domain=demo.local <wait>",
|
||||
"fb=false <wait>",
|
||||
"debconf/frontend=noninteractive <wait>",
|
||||
"console-setup/ask_detect=false <wait>",
|
||||
"console-keymaps-at/keymap=de <wait>",
|
||||
"keyboard-configuration/xkb-keymap=de <wait>",
|
||||
"<enter><wait>"
|
||||
],
|
||||
"memory": "1024",
|
||||
"qemuargs": [
|
||||
["-display", "sdl"]
|
||||
]
|
||||
}
|
||||
],
|
||||
"provisioners": [
|
||||
{
|
||||
"type": "shell",
|
||||
"execute_command": "{{ .Vars }} sudo -E /bin/sh '{{ .Path }}'",
|
||||
"scripts": [
|
||||
"scripts/babelbox-partitions.sh",
|
||||
"scripts/setup-babelbox.sh"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "shell",
|
||||
"only": [
|
||||
"virtualbox-iso"
|
||||
],
|
||||
"execute_command": "{{ .Vars }} sudo -E /bin/sh '{{ .Path }}'",
|
||||
"scripts": [
|
||||
"scripts/virtualbox.sh"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "shell",
|
||||
"execute_command": "{{ .Vars }} sudo -E /bin/sh '{{ .Path }}'",
|
||||
"scripts": [
|
||||
"scripts/cleanup.sh",
|
||||
"scripts/minimize.sh"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
1
http-qemu/README.txt
Normal file
1
http-qemu/README.txt
Normal file
|
@ -0,0 +1 @@
|
|||
this directory contains files that are served by packer via HTTP
|
97
http-qemu/preseed.cfg
Normal file
97
http-qemu/preseed.cfg
Normal file
|
@ -0,0 +1,97 @@
|
|||
### Localization
|
||||
d-i debian-installer/locale string en_US
|
||||
d-i debian-installer/language string en
|
||||
d-i debian-installer/country string US
|
||||
d-i debian-installer/locale string en_US.UTF-8
|
||||
d-i localechooser/supported-locales multiselect en_US.UTF-8, de_DE.UTF-8
|
||||
|
||||
# Keyboard selection.
|
||||
d-i console-tools/archs select at
|
||||
d-i console-keymaps-at/keymap select de
|
||||
|
||||
d-i keyboard-configuration/xkb-keymap select de
|
||||
|
||||
### Network configuration
|
||||
d-i netcfg/choose_interface select auto
|
||||
|
||||
### Mirror settings
|
||||
d-i mirror/country string manual
|
||||
d-i mirror/http/hostname string httpredir.debian.org
|
||||
d-i mirror/http/directory string /debian
|
||||
d-i mirror/http/proxy string
|
||||
|
||||
### Account setup
|
||||
d-i passwd/root-login boolean false
|
||||
d-i passwd/user-fullname string Babelbox Demo User
|
||||
d-i passwd/username string demo
|
||||
d-i passwd/user-password-crypted password $6$M0jXQ0qT0W$4aZR9JeivSUot1WpUv5elFOEz2lZ6D4a67NMu40OR3ocHeDQIN.bkBV/JAGINgZ9tp.yLQL7wGGhLM2ZJZ9Mp/
|
||||
|
||||
### Clock and time zone setup
|
||||
d-i clock-setup/utc boolean true
|
||||
d-i time/zone string GMT+0
|
||||
d-i clock-setup/ntp boolean false
|
||||
|
||||
### Partitioning
|
||||
d-i partman-lvm/purge_lvm_from_device boolean true
|
||||
d-i partman-lvm/device_remove_lvm boolean true
|
||||
d-i partman-lvm/confirm boolean true
|
||||
d-i partman-lvm/confirm_nooverwrite boolean true
|
||||
|
||||
d-i partman-md/device_remove_md boolean true
|
||||
|
||||
d-i partman-auto/disk string /dev/vda
|
||||
d-i partman-auto/method string regular
|
||||
d-i partman-auto/expert_recipe string \
|
||||
root :: \
|
||||
6144 50 6144 ext4 \
|
||||
$primary{ } $bootable{ } \
|
||||
method{ format } format{ } \
|
||||
use_filesystem{ } filesystem{ ext4 } \
|
||||
mountpoint{ / } \
|
||||
. \
|
||||
512 90 512 linux-swap \
|
||||
$primary{ } \
|
||||
method{ swap } \
|
||||
format{ } \
|
||||
. \
|
||||
1 1000 -1 ext4 \
|
||||
$primary{ } \
|
||||
method{ keep } \
|
||||
.
|
||||
d-i partman-auto/choose_recipe select root
|
||||
d-i partman-basicmethods/method_only boolean false
|
||||
d-i partman-partitioning/confirm_write_new_label boolean true
|
||||
d-i partman/choose_partition select finish
|
||||
d-i partman/confirm boolean true
|
||||
d-i partman/confirm_nooverwrite boolean true
|
||||
|
||||
### Apt setup
|
||||
d-i apt-setup/non-free boolean false
|
||||
d-i apt-setup/contrib boolean false
|
||||
d-i apt-setup/cdrom/set-first boolean false
|
||||
d-i apt-setup/cdrom/set-next boolean false
|
||||
d-i apt-setup/cdrom/set-failed boolean false
|
||||
d-i base-installer/install-recommends boolean false
|
||||
d-i apt-setup/services-select multiselect security, updates
|
||||
d-i apt-setup/security_host string security.debian.org
|
||||
|
||||
### Package selection
|
||||
tasksel tasksel/first multiselect standard
|
||||
|
||||
d-i pkgsel/include string parted openssh-server acpid sudo ca-certificates curl
|
||||
d-i pkgsel/upgrade select safe-upgrade
|
||||
|
||||
popularity-contest popularity-contest/participate boolean false
|
||||
|
||||
### GRUB
|
||||
d-i grub-installer/only_debian boolean true
|
||||
d-i grub-installer/bootdev string default
|
||||
|
||||
### Finishing up the installation
|
||||
d-i finish-install/keep-consoles boolean true
|
||||
d-i finish-install/reboot_in_progress note
|
||||
|
||||
# Setup passwordless sudo for demo
|
||||
d-i preseed/late_command string \
|
||||
echo "demo ALL=(ALL:ALL) NOPASSWD:ALL" > /target/etc/sudoers.d/demo ; \
|
||||
in-target chmod 0440 /etc/sudoers.d/demo
|
|
@ -2,6 +2,18 @@
|
|||
|
||||
set -e
|
||||
|
||||
case "$PACKER_BUILDER_TYPE" in
|
||||
virtualbox-iso)
|
||||
DEVICE=/dev/sda
|
||||
;;
|
||||
qemu)
|
||||
DEVICE=/dev/vda
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported packer build $PACKER_BUILDER_TYPE" >&2
|
||||
exit 1
|
||||
esac
|
||||
|
||||
echo "
|
||||
d
|
||||
3
|
||||
|
@ -14,5 +26,5 @@ n
|
|||
p
|
||||
|
||||
|
||||
w" | /sbin/fdisk /dev/sda || true
|
||||
w" | /sbin/fdisk "$DEVICE" || true
|
||||
/sbin/partprobe
|
||||
|
|
Loading…
Reference in a new issue