hashicorp / packer

Packer is a tool for creating identical machine images for multiple platforms from a single source configuration.
http://www.packer.io
Other
15.13k stars 3.33k forks source link

proxmox-iso Builder - additional_iso_files Not Appearing #10382

Closed tgihf closed 3 years ago

tgihf commented 3 years ago

proxmox-iso Builder - additional_iso_files Not Appearing

I'm attempting to use Packer to automate the build of a Windows 10 template in Proxmox, similar to https://holdmybeersecurity.com/2020/10/03/creating-a-windows-10-64-bit-vm-on-proxmox-with-packer-v1-6-3-and-vault/.

Even when using the additional_iso_files field (according to https://www.packer.io/docs/builders/proxmox/iso), the additional CD/DVD Drives that are supposed to contain the additional ISOs are not attached to the virtual machine when it boots up.

If I power off the VM, manually attach the two ISOs as CD/DVD drives, and then power on the VM, everything works great. The primary issue seems to be that the additional_iso_files field isn't working.

Packer version

Packer version: 1.6.5

Simplified Packer Buildfile

{
  "variables": {
    "proxmox_url": "https://pve:8006/api2/json",
    "proxmox_host": "pve",
    "proxmox_username": "root@pam",
    "proxmox_password": "fake-password",
    "proxmox_skip_tls_verify": "true",

    "winrm_username": "Administrator",
    "winrm_password": "fake-password",
    "vm_name": "win-10-x64-template",
    "template_description": "Windows 10 x64 Template by Packer",
    "iso_file": "ISOs:iso/en_windows_10_consumer_editions_version_2004_x64_dvd_36d61c40.iso",

    "vm_cpu_cores": "4",
    "vm_memory": "2048",
    "vm_disk_size": "20G"
  },

  "builders": [
    {
      "type": "proxmox",
      "node": "{{user `proxmox_host`}}",
      "proxmox_url":  "{{user `proxmox_url`}}",
      "insecure_skip_tls_verify": "{{ user `proxmox_skip_tls_verify` }}",
      "username": "{{ user `proxmox_username` }}",
      "password": "{{ user `proxmox_password` }}",
      "vm_name": "{{ user `vm_name` }}",
      "template_description": "{{ user `template_description` }}",
      "iso_file": "{{ user `iso_file` }}",
      "memory": "{{ user `vm_memory` }}",
      "cores": "{{ user `vm_cpu_cores` }}",
      "os": "win10",
      "network_adapters": [
        {
          "model": "e1000",
          "bridge": "vmbr0"
        }
      ],
      "disks": [
        {
          "type": "sata",
          "disk_size": "{{ user `vm_disk_size` }}",
          "storage_pool": "vm-storage",
          "storage_pool_type": "zfspool",
          "format": "raw"
        }
      ],
      "http_directory": "http",
      "additional_iso_files": [
        {
          "device": "sata1",
          "iso_file": "local:iso/Autounattend.iso",
          "unmount": false
        },
        {
          "device": "sata2",
          "iso_file": "ISOs:iso/virtio-win-0.1.185.iso",
          "unmount": false
        }
      ], 
      "communicator": "winrm",
      "winrm_username": "{{ user `winrm_username` }}",
      "winrm_password": "{{ user `winrm_password` }}",
      "winrm_insecure": true,
      "winrm_use_ssl": true
    }
  ],
  "provisioners": [
    {
      "type": "windows-shell",
      "scripts": [
        "scripts/disablewinupdate.bat"
      ]
    },
    {
      "type": "powershell",
      "scripts": [
        "scripts/disable-hibernate.ps1"
      ]
    }
  ]
}

Operating system and Environment details

Proxmox version: 6.2-4 Packer host: macOS Mojave (Version 10.14.6)

Log Fragments and crash.log files

Output from build command packer build win10x64-enterprise.json:

2020/12/12 23:49:46 Build debug mode: false
proxmox: output will be in this color.
2020/12/12 23:49:46 Force build: false
2020/12/12 23:49:46 On error: 

2020/12/12 23:49:46 Waiting on builds to complete...
2020/12/12 23:49:46 Starting build run: proxmox
2020/12/12 23:49:46 Running builder: proxmox
2020/12/12 23:49:46 [INFO] (telemetry) Starting builder proxmox
2020/12/12 23:49:46 packer-builder-proxmox plugin: No URLs were provided to Step Download. Continuing...
2020/12/12 23:49:46 packer-builder-proxmox plugin: No URLs were provided to Step Download. Continuing...
2020/12/12 23:49:46 packer-builder-proxmox plugin: No URLs were provided to Step Download. Continuing...
==> proxmox: Creating VM
==> proxmox: No VM ID given, getting next free from Proxmox
==> proxmox: Starting VM
2020/12/12 23:49:48 packer-builder-proxmox plugin: Found available port: 8856 on IP: 0.0.0.0
==> proxmox: Starting HTTP server on port 8856
2020/12/12 23:49:48 packer-builder-proxmox plugin: No boot command given, skipping
2020/12/12 23:49:51 packer-builder-proxmox plugin: [DEBUG] Unable to get address during connection step: 500 QEMU guest agent is not running
2020/12/12 23:49:51 packer-builder-proxmox plugin: Waiting for WinRM, up to timeout: 30m0s
==> proxmox: Waiting for WinRM to become available...
2020/12/12 23:49:54 packer-builder-proxmox plugin: [DEBUG] Error getting WinRM host: 500 QEMU guest agent is not running
tgihf commented 3 years ago
Screen Shot 2020-12-13 at 12 03 50 AM

Here's a screenshot of the VM after performing the build. You can see the additional iso files are not attached.

nils-tekampe commented 3 years ago

Same issue here. Packer version 1.6.5 under OS-X

jakjablonski commented 3 years ago

Same issue. Packer v1.6.6 and Proxmox 6.3-3

carlpett commented 3 years ago

Hi, Just so I'm looking for the right bug - is the issue that the ISOs are not mounted during the build, or that they do not remain afterwards? It seems there are two different cases in this thread (and both might be broken).

jakjablonski commented 3 years ago

In my case, the ISOs are not mounted during the build. The windows install process stops on language selections and waits. If I manually power off VM, mount Autounattend.iso and virtio-win.iso, then power on VM the build works correctly.

carlpett commented 3 years ago

Right, it looks like files were actually never mounted as part of the build, only when converting to a template. I assume there's another use-case for that, and I simply missed checking this one during review. I'll try to write up the missing code.

carlpett commented 3 years ago

The patch was a bit more complicated than expected, but I've opened a PR now. Would any of you be able to check it out and verify it works in your usecases? @tgihf @nils-tekampe @jakjablonski

ghost commented 3 years ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.