Packer KVM: Unterschied zwischen den Versionen

Aus Xinux Wiki
Zur Navigation springen Zur Suche springen
 
(10 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 1: Zeile 1:
 +
=Webserver=
 +
*[[Packer Webserver]]
 +
=KVM Host=
 +
==Packer Build File==
 +
*~/packer/debian-kvm.json
 
<syntaxhighlight lang=json>
 
<syntaxhighlight lang=json>
 
{
 
{
Zeile 20: Zeile 25:
 
         " debconf/priority=critical",
 
         " debconf/priority=critical",
 
         " preseed/url=http://daisy.xinux.org/preseed/debian11/preseed.cfg <wait>",
 
         " preseed/url=http://daisy.xinux.org/preseed/debian11/preseed.cfg <wait>",
         "debian-installer=de_DE.UTF-8 <wait>",<pre>
+
         "debian-installer=de_DE.UTF-8 <wait>",
 
 
 
         "auto <wait>",
 
         "auto <wait>",
 
         "locale=de_DE.UTF-8 <wait>",
 
         "locale=de_DE.UTF-8 <wait>",
Zeile 34: Zeile 38:
 
       ],
 
       ],
 
       "qemuargs": [
 
       "qemuargs": [
                 ["-display", "gtk"]<pre>
+
                 ["-display", "gtk"]
  
 
             ],
 
             ],
Zeile 40: Zeile 44:
 
       "ssh_username": "vagrant",
 
       "ssh_username": "vagrant",
 
       "ssh_timeout": "15m",
 
       "ssh_timeout": "15m",
       "ssh_password": "vagrant",
+
       "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"
 
       "shutdown_command": "echo 'vagrant' | sudo -S /sbin/shutdown -hP now"
 
     }
 
     }
Zeile 46: Zeile 50:
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
<syntaxhighlight>
 
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
+
==Bild Vorgang starten==
d-i partman/choose_partition select finish
+
*packer build debian11-qemu.json
d-i partman/confirm boolean true
+
<pre>
d-i partman/confirm_nooverwrite boolean true
+
qemu output will be in this color.
d-i partman/confirm_write_new_label boolean true
+
 
d-i passwd/root-login boolean false
+
==> qemu: Retrieving ISO
d-i passwd/root-password-again password vagrant
+
    qemu: Found already downloaded, initial checksum matched, no download needed: http://daisy.xinux.org/isos/debian-11.3.0-amd64-netinst.iso
d-i passwd/root-password password vagrant
+
==> qemu: Creating hard drive...
d-i passwd/user-fullname string vagrant
+
==> qemu: Starting HTTP server on port 8603
d-i passwd/user-uid string 1000
+
==> qemu: Found port for communicator (SSH, WinRM, etc): 2970.
d-i passwd/user-password password vagrant
+
==> qemu: Looking for available port between 5900 and 6000 on 127.0.0.1
d-i passwd/user-password-again password vagrant
+
==> qemu: Starting VM, booting from CD-ROM
d-i passwd/username string vagrant
+
==> qemu: Overriding defaults Qemu arguments with QemuArgs...
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
+
==> qemu: Waiting 10s for boot...
d-i pkgsel/install-language-support boolean false
+
==> qemu: Connecting to VM via VNC (127.0.0.1:5903)
d-i pkgsel/update-policy select none
+
==> qemu: Typing the boot command over VNC...
d-i pkgsel/upgrade select full-upgrade
+
</pre>
# Prevent packaged version of VirtualBox Guest Additions being installed:
+
[[Datei:Packer-1.png]]
d-i preseed/early_command string sed -i \
+
==Abschluss der Installation==
  '/in-target/idiscover(){/sbin/discover|grep -v VirtualBox;}' \
+
<pre>
  /usr/lib/pre-pkgsel.d/20install-hwpackages
+
==> qemu: Using ssh communicator to connect: 127.0.0.1
d-i time/zone string UTC
+
==> qemu: Waiting for SSH to become available...
d-i user-setup/allow-password-weak boolean true
+
==> qemu: Connected to SSH!
d-i user-setup/encrypt-home boolean false
+
==> qemu: Gracefully halting virtual machine...
d-i preseed/late_command string sed -i '/^deb cdrom:/s/^/#/' /target/etc/apt/sources.list
+
    qemu:
apt-cdrom-setup apt-setup/cdrom/set-first boolean false
+
    qemu: Wir gehen davon aus, dass der lokale Systemadministrator Ihnen die
apt-mirror-setup apt-setup/use_mirror boolean true
+
    qemu: Regeln erklärt hat. Normalerweise läuft es auf drei Regeln hinaus:
popularity-contest popularity-contest/participate boolean false
+
    qemu:
tasksel tasksel/first multiselect standard, ssh-server
+
    qemu:    #1) Respektieren Sie die Privatsphäre anderer.
</syntaxhighlight>
+
    qemu:    #2) Denken Sie nach, bevor Sie tippen.
 +
    qemu:     #3) Mit großer Macht kommt große Verantwortung.
 +
    qemu:
 +
    qemu: [sudo] Passwort für vagrant:
 +
==> qemu: Converting hard drive...
 +
Build 'qemu' finished.
 +
 
 +
==> Builds finished. The artifacts of successful builds are:
 +
--> qemu: VM files in directory: output-qemu
 +
</pre>
 +
==Ergebnis==
 +
*file output-qemu/packer-qemu
 +
output-qemu/packer-qemu: QEMU QCOW2 Image (v3), 5242880000 bytes

Aktuelle Version vom 5. April 2022, 13:30 Uhr

Webserver

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_DE.UTF-8 <wait>",
        "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"]

            ],
      "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...

Packer-1.png

Abschluss der Installation

==> qemu: Using ssh communicator to connect: 127.0.0.1
==> qemu: Waiting for SSH to become available...
==> qemu: Connected to SSH!
==> qemu: Gracefully halting virtual machine...
    qemu:
    qemu: Wir gehen davon aus, dass der lokale Systemadministrator Ihnen die
    qemu: Regeln erklärt hat.  Normalerweise läuft es auf drei Regeln hinaus:
    qemu:
    qemu:     #1) Respektieren Sie die Privatsphäre anderer.
    qemu:     #2) Denken Sie nach, bevor Sie tippen.
    qemu:     #3) Mit großer Macht kommt große Verantwortung.
    qemu:
    qemu: [sudo] Passwort für vagrant:
==> qemu: Converting hard drive...
Build 'qemu' finished.

==> Builds finished. The artifacts of successful builds are:
--> qemu: VM files in directory: output-qemu

Ergebnis

  • file output-qemu/packer-qemu
output-qemu/packer-qemu: QEMU QCOW2 Image (v3), 5242880000 bytes