Packer KVM

Aus Xinux Wiki
Zur Navigation springen Zur Suche springen

Webserver

Preceed File

  • /var/www/html/preseed/debian11/preseed.cfg
choose-mirror-bin mirror/http/proxy string
d-i apt-setup/use_mirror boolean true
d-i base-installer/kernel/override-image string linux-server
d-i clock-setup/utc boolean true
d-i clock-setup/utc-auto boolean true
d-i finish-install/reboot_in_progress note
d-i grub-installer/only_debian boolean true
d-i grub-installer/with_other_os boolean true
d-i keymap select us
d-i mirror/country string manual
d-i mirror/http/directory string /debian
d-i mirror/http/hostname string httpredir.debian.org
d-i mirror/http/proxy string
d-i partman-auto/disk string
d-i partman-auto/method string regular
d-i partman-auto/expert_recipe string                         \
      boot-root ::                                            \
              512 512 300% linux-swap                          \
                      $primary{ }                             \
                      method{ swap } format{ }                \
              .                                               \
              4000 10000 1000000000 ext4                       \
                      $primary{ }                             \
                      method{ format } format{ }              \
                      use_filesystem{ } filesystem{ ext3 }    \
                      mountpoint{ / }                         \
              .

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
d-i partman/confirm_write_new_label boolean true
d-i passwd/root-login boolean false
d-i passwd/root-password-again password vagrant
d-i passwd/root-password password vagrant
d-i passwd/user-fullname string vagrant
d-i passwd/user-uid string 1000
d-i passwd/user-password password vagrant
d-i passwd/user-password-again password vagrant
d-i passwd/username string vagrant
d-i pkgsel/include string sudo bzip2 acpid cryptsetup zlib1g-dev wget curl dkms fuse make nfs-common net-tools cifs-utils rsync cloud-init
d-i pkgsel/install-language-support boolean false
d-i pkgsel/update-policy select none
d-i pkgsel/upgrade select full-upgrade
# Prevent packaged version of VirtualBox Guest Additions being installed:
d-i preseed/early_command string sed -i \
  '/in-target/idiscover(){/sbin/discover|grep -v VirtualBox;}' \
  /usr/lib/pre-pkgsel.d/20install-hwpackages
d-i time/zone string UTC
d-i user-setup/allow-password-weak boolean true
d-i user-setup/encrypt-home boolean false
d-i preseed/late_command string sed -i '/^deb cdrom:/s/^/#/' /target/etc/apt/sources.list
apt-cdrom-setup apt-setup/cdrom/set-first boolean false
apt-mirror-setup apt-setup/use_mirror boolean true
popularity-contest popularity-contest/participate boolean false
tasksel tasksel/first multiselect standard, ssh-server

Ablegen der ISO Datei

  • /var/www/html/isos/debian-11.3.0-amd64-netinst.iso

KVM Host

Packer Build File

  • ~/packer/debian-kvm.json
{
  "builders": [
    {
      "type": "qemu",
      "disk_size": "5000",
      "format": "qcow2",
      "accelerator": "kvm",
      "iso_url": "http://daisy.xinux.org/isos/debian-11.3.0-amd64-netinst.iso",
      "iso_checksum_type": "sha256",
      "iso_checksum": "7892981e1da216e79fb3a1536ce5ebab157afdd20048fe458f2ae34fbc26c19b",
      "http_directory": "config",
      "boot_wait": "10s",
      "boot_command": [
        "<esc><wait>",
        "install <wait>",
        "/install/vmlinuz<wait>",
        " initrd=/install/initrd.gz",
        " auto-install/enable=true",
        " debconf/priority=critical",
        " preseed/url=http://daisy.xinux.org/preseed/debian11/preseed.cfg <wait>",
        "debian-installer=de_DEhttp://daisy.xinux.org/isos/debian-11.3.0-amd64-netinst.iso.UTF-8 <wait>",<pre>

        "auto <wait>",
        "locale=de_DE.UTF-8 <wait>",
        "kbd-chooser/method=us <wait>",
        "keyboard-configuration/xkb-keymap=de <wait>",
        "fb=false <wait>",
        "debconf/frontend=noninteractive <wait>",
        "console-setup/ask_detect=false <wait>",
        "console-keymaps-at/keymap=de <wait>",
        "grub-installer/bootdev=/dev/vda <wait>",
        "<enter><wait>"
      ],
      "qemuargs": [
                ["-display", "gtk"]<pre>

            ],
      "memory": "4096",
      "ssh_username": "vagrant",
      "ssh_timeout": "15m",
      "ssh_password": "vagrant",http://daisy.xinux.org/isos/debian-11.3.0-amd64-netinst.iso
      "shutdown_command": "echo 'vagrant' | sudo -S /sbin/shutdown -hP now"
    }
  ]
}

Bild Vorgang starten

  • packer build debian11-qemu.json
qemu output will be in this color.

==> qemu: Retrieving ISO
    qemu: Found already downloaded, initial checksum matched, no download needed: http://daisy.xinux.org/isos/debian-11.3.0-amd64-netinst.iso
==> qemu: Creating hard drive...
==> qemu: Starting HTTP server on port 8603
==> qemu: Found port for communicator (SSH, WinRM, etc): 2970.
==> qemu: Looking for available port between 5900 and 6000 on 127.0.0.1
==> qemu: Starting VM, booting from CD-ROM
==> qemu: Overriding defaults Qemu arguments with QemuArgs...
==> qemu: Waiting 10s for boot...
==> qemu: Connecting to VM via VNC (127.0.0.1:5903)
==> qemu: Typing the boot command over VNC...