Giter Club home page Giter Club logo

packer-plugin-proxmox's Introduction

Packer Plugin Proxmox

The Proxmox multi-component plugin can be used with HashiCorp Packer to create custom images. For the full list of available features for this plugin see docs.

Note

Releases prior to v1.1.0 were incorrectly registered as proxmox-promox-iso and proxmox-proxmox-clone. You are encouraged to upgrade any locally installed version of this plugin to v1.1.0. Refer to Plugin loading issue for more details.

Installation

Using pre-built releases

Using the packer init command

Starting from version 1.7, Packer supports a new packer init command allowing automatic installation of Packer plugins. Read the Packer documentation for more information.

To install this plugin, copy and paste this code into your Packer configuration . Then, run packer init.

packer {
  required_plugins {
    proxmox = {
      version = ">= 1.1.8"
      source  = "github.com/hashicorp/proxmox"
    }
  }
}

Manual installation

You can find pre-built binary releases of the plugin here. Once you have downloaded the latest archive corresponding to your target OS, uncompress it to retrieve the plugin binary file corresponding to your platform. To install the plugin, please follow the Packer documentation on installing a plugin.

From Sources

If you prefer to build the plugin from sources, clone the GitHub repository locally and run the command go build from the root directory. Upon successful compilation, a packer-plugin-proxmox plugin binary file can be found in the root directory. To install the compiled plugin, please follow the official Packer documentation on installing a plugin.

Configuration

For more information on how to configure the plugin, please read the documentation located in the docs/ directory.

Contributing

  • If you think you've found a bug in the code or you have a question regarding the usage of this software, please reach out to us by opening an issue in this GitHub repository.
  • Contributions to this project are welcome: if you want to add a feature or a fix a bug, please do so by opening a Pull Request in this GitHub repository. In case of feature contribution, we kindly ask you to open an issue to discuss it beforehand.

packer-plugin-proxmox's People

Contributors

alex-sector avatar azr avatar bouchardh avatar carlpett avatar chrismarget avatar dependabot[bot] avatar elt4n1n avatar featheredtoast avatar hashicorp-copywrite[bot] avatar jeinwag avatar jescalan avatar joeyberkovitz avatar karliemeads avatar lbajolet-hashicorp avatar loloolllool avatar mabeett avatar mizhka avatar modrake avatar mpywell avatar nywilken avatar paginabianca avatar rhpijnacker avatar romantomjak avatar sebastian-de avatar stephen-fox avatar swampdragons avatar sylviamoss avatar xrayj11 avatar zaenk avatar zaventh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

packer-plugin-proxmox's Issues

Add "convert_to_template" option to iso and clone builders

Please search the existing issues for relevant feature requests, and use the
reaction feature
(https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/)
to add upvotes to pre-existing requests.

Community Note

Please vote on this issue by adding a ๐Ÿ‘ reaction to the original issue to help the community and maintainers prioritize this request.
Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request.
If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Description

This feature will add a "convert_to_template" option to the proxmox-iso and proxmox-clone builders. The option will instruct this plugin to keep the machine image as a VM or convert it to a template.

Use Case(s)

Gives the user more control over the created machine image.

Potential configuration

convert_to_template = true|false

Potential References

The packer vsphere-iso and vsphere-clone builders have similar functionality

https://www.packer.io/plugins/builders/vsphere/vsphere-iso#convert_to_template

Unable to create qcow2 format disks

Packer creates the VM always with raw disks only, no matter what disk format is defined in disks block. Here's my disk configuration.

disks {
storage_pool = var.isoStore
storage_pool_type = "directory"
type = "virtio"
disk_size = var.diskSize
cache_mode = "none"
format = "qcow2"
}

It creates VM with a raw disk always. I tried changing the disk type to iscsi, format to qcow etc. but that did not help.

I use the Packer version 1.7.3 on Ubuntu 20.04 and trying to create a template of Ubuntu 20.04.

Proxmox builder - Error getting SSH address 500 QEMU guest agent is not running

hashicorp/packer#9115
This issue relates to much of the discussion in the one linked above, however, at present I have a very specific issue which I think is worth separating out.

Packer version:

goffinf@DESKTOP-LH5LG1V:~$ packer version
Packer v1.6.0

Builder: proxmox

Proxmox version:

pveversion --verbose
proxmox-ve: 6.2-1 (running kernel: 5.4.44-1-pve)
pve-manager: 6.2-6 (running version: 6.2-6/ee1d7754)
pve-kernel-5.4: 6.2-3
pve-kernel-helper: 6.2-3
pve-kernel-5.4.44-1-pve: 5.4.44-1
pve-kernel-5.4.34-1-pve: 5.4.34-2
...

I am trying to run a Packer build using the ubuntu-20.04-live-server-amd64.iso, but when the boot_command runs the build just hangs waiting to get an SSH connection to the launched instance. When the ssh_timeout is reached the build fails and the VM is destroyed.

The Packer log reports that the SSH address cannot be obtained because the QEMU guest agent isn't running. Clearly that is not installed on a fresh ISO. I also set the communicator to ssh, disabled the qemu_agent, and configured an alternate ssh_port, so I'm not sure why this is happening ?

...
  "builders": [
    {
      ...
      "communicator": "ssh",
...
      "qemu_agent": false,
      "ssh_handshake_attempts": "50",
      "ssh_username": "{{user `ssh_username`}}",
      "ssh_password": "{{user `ssh_password`}}",
      "ssh_port": 2222,
      "ssh_pty": true,
      "ssh_timeout": "{{user `ssh_timeout`}}",

packer log:
image

build times-out:
image

From the related thread:

The new Ubuntu Server installer starts an SSH server.
The credentials are installer:<random_pw>
Packer wrongfully tries to connect to this SSH, thinking the VM is ready for further provisioning steps - which it is NOT.

Thanks to @JulyIghor we found a workaround.
We simply change the port packer expects the ssh server to run at to something else AND during cloud-init late_commands we override the servers port accordingly. That way once the cloud-init finishes and reboots the VM the ssh server will run at the new port - now packer picks up on that and continues provisiong as we are used to.

As a last step durng provision, we remove the conf file, essentially resettign the ssh server port back to default 22.

I have tried using a different ssh_port (2222 in the example below), but that had no effect.

For completeness, the boot_command, does result in the newly launched VM entering the correct autoinstall process (rather than the standard install dialogue) as evidenced by the following screen shots taken during a Packer debug build:

image

image

I have copied the complete Packer build file and the user-data below.

Any guidance on how to ensure that the Packer build uses ssh rather than the qemu agent would be much appreciated (or anything else you think might be the culprit).

Kind Regards

Fraser.

host.json:

{
  "builders": [
    {
      "boot_command": [
        "<enter><enter><f6><esc><wait>",
        "autoinstall ds=nocloud-net;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/",
        "<enter>"
      ],
      "boot_wait": "{{user `boot_wait`}}",
      "communicator": "ssh",
      "disks": [
        {
          "disk_size": "{{user `home_volume_size`}}",
          "storage_pool": "local-lvm",
          "storage_pool_type": "lvm-thin",
          "type": "scsi",
          "format": "raw"
        }
      ],
      "http_directory": "{{user `http_directory`}}",
      "insecure_skip_tls_verify": true,
      "iso_checksum": "{{user `iso_checksum_type`}}:{{user `iso_checksum`}}",
      "iso_file": "{{user `iso_file`}}",
      "memory": 2048,
      "name": "ubuntu-20-04-base",
      "network_adapters": [
        {
          "bridge": "vmbr0",
          "model": "virtio"
        }
      ],
      "node": "{{user `proxmox_target_node`}}",
      "password": "{{user `proxmox_server_pwd`}}",
      "proxmox_url": "https://{{user `proxmox_server_hostname`}}:{{user `proxmox_server_port`}}/api2/json",
      "qemu_agent": false,
      "ssh_handshake_attempts": "50",
      "ssh_username": "{{user `ssh_username`}}",
      "ssh_password": "{{user `ssh_password`}}",
      "ssh_port": 2222,
      "ssh_pty": true,
      "ssh_timeout": "{{user `ssh_timeout`}}",
      "type": "proxmox",
      "unmount_iso": true,
      "username": "{{user `proxmox_server_user`}}"
    }
  ],
  "provisioners": [
    {
      "execute_command": "{{ .Vars }} sudo -E -S sh '{{ .Path }}'",
      "inline": [
        "ls /"
      ],
      "type": "shell"
    }
  ],
  "variables": {
    "boot_wait": "2s",
    "http_directory": "http",
    "iso_checksum": "caf3fd69c77c439f162e2ba6040e9c320c4ff0d69aad1340a514319a9264df9f",
    "iso_checksum_type": "sha256",
    "iso_file": "local:iso/ubuntu-20.04-live-server-amd64.iso",
    "proxmox_server_hostname": "proxmox-002",
    "proxmox_server_port": "8006",
    "proxmox_server_pwd": "xxxxxxx",
    "proxmox_server_user": "xxxxxxxx",
    "proxmox_target_node": "home",
    "ssh_handshake_attempts": "20",
    "ssh_password": "ubuntu",
    "ssh_username": "ubuntu",
    "ssh_timeout": "10m"
  }
}

user-data:

#cloud-config
autoinstall:
  identity:
    hostname: ubuntu-20-04-base
    password: '$6$wdAcoXrU039hKYPd$508Qvbe7ObUnxoj15DRCkzC3qO7edjH0VV7BPNRDYK4QR8ofJaEEF2heacn0QgD.f8pO8SNp83XNdWG6tocBM1'
    username: ubuntu
  keyboard:
    layout: gb
    variant: uk
  late-commands:
    - sed -i 's/^#*\(send dhcp-client-identifier\).*$/\1 = hardware;/' /target/etc/dhcp/dhclient.conf
    - 'sed -i "s/dhcp4: true/&\n      dhcp-identifier: mac/" /target/etc/netplan/00-installer-config.yaml'
  locale: en_GB.UTF-8
  network:
    network:
      version: 2
      ethernets:
        ens33:
          dhcp4: true
          dhcp-identifier: mac
  ssh:
    allow-pw: true
    authorized-keys:
    - "ssh-rsa AAAAB3NzaC1yc2...."
    install-server: true
  version: 1

Crash when running Proxmox builder

This issue was originally opened by @ProfessorSalty in hashicorp/packer#11478 and has been migrated to this repository. The original issue description is below.


Overview of the Issue

Trying to create a CentOS 8 template on my Proxmox server using Packer. The entire repository is here, but relevant files are linked below. Build immediately fails because Unexpected EOF

Reproduction Steps

Using this Packer Template and this variables file (as tmp.json):
{ "proxmox_host": "test.local", "proxmox_node": "node1", "proxmox_user": "automation@pve", "iso_storage": "diskimages", "proxmox_api_token": { "id": "build", "secret": "1234" }, "controller_ssh_pub_key_file": "~/.ssh/id_ed25519.pub", "iso_file": "CentOS-7.5.2111-x86_64-boot.iso", "template_name": "centos-template", "template_username": "toor", "template_user_password": "secretpassword", "template_description": "Ready-to-run build of CentOS 8 with minimal additions and some things taken out", "proxmox_vm_id": "9001", "root_password": "secretrootpassword", "hostname": "centos-template" }

packer build -var="timezone=America/New_York" -var="template-name=centos-8" -var-file=tmp.json images/centos-8

Packer version

Packer v1.7.8

Packer Template

https://github.com/ProfessorSalty/homelab-provisioning/blob/master/images/centos-8/main.pkr.hcl

Operating system and Environment details

Packer on Linux Ubuntu 21.10
Targeting Proxmox VE 7.0-11

Packer configuration validates just fine
packer validate -var-file=tmp.json -var="timezone=America/New_York" -var="template-name=centos-8" images/centos-8/main.pkr.hcl

Log Fragments and crash.log files

https://gist.github.com/ProfessorSalty/e35757d5f22de1617f0dd34fcf768413

Underscore not allowed in template name

Overview of the Issue

When using an underscore in the template_name configuration option, building of the image will fail with:

Error updating template: 400 Parameter verification failed.

With commit 66dd01b a check for spaces in the template name was introduced, but an underscore is an invalid character as well. This is shown in the Proxmox web UI when trying to use it in a template name:

proxmox_template_name

Reproduction Steps

Set a name for the template with an underscore in it, for example:

template_name        = "centos_stream-8"

Plugin and Packer version

Packer v1.7.2

Boot Command Extensions

Please search the existing issues for relevant feature requests, and use the
reaction feature
(https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/)
to add upvotes to pre-existing requests.

Community Note

Please vote on this issue by adding a ๐Ÿ‘ reaction to the original issue to help the community and maintainers prioritize this request.
Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request.
If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Description

There's a few things I'm hoping for from this.

  1. Compound 'boot commands' ie <ctrl+key> or <ctrl+shift+key> or <<ctrl><shift><key>>
  2. More boot commands <a>, <b>, <c>
  3. Boot command repetitions ie <bs99>

Use Case(s)

I'm currently working to get ubuntu-21.10-live-server-amd64 to AutoInstall. I just recently completed one for 20.04, but there's a change in how they do Boot Commands in 21. Instead of the GRUB command-line just accepting GRUB commands, they have a "bash-like" command-line that seems to accept a subset of the commands. Which don't include things like autoinstall. However they do have the option to enter e to open an emacs editor that "edits the commands before booting" which is what the GRUB commandline did in 20.04.

I can get this to work by just retyping the keystroke commands ( literally 99 times), but this is obviously not ideal.

If key strokes for every alphanumeric could be added and compound keystrokes were a thing then we could take advantage of the Emacs language features. If nothing else having boot command repetition would significantly cut down on the ugliness and errors involved in configuration files.

Potential references/configs

I think this may need to be fixed/extended somewhere in here
https://github.com/hashicorp/packer-plugin-sdk/tree/main/bootcommand

I'd love to be able to extend this myself, but I don't have the confidence with GoLang to make it happen just yet.
I'm also going to submit this in the packer-plugin-sdk repo too, incase thats where it needs to be.

full json and hcl example are missing

When filing a bug, please include the following headings if possible. Any
example text in this template can be deleted.

Overview of the Issue

form https://github.com/hashicorp/packer-plugin-scaffolding/tree/main/example
This folder must contain a fully working example of the plugin usage. The example must define the required_plugins block. A pre-defined GitHub Action will run packer init, packer validate, and packer build to test your plugin with the latest version available of Packer.

Reproduction Steps

git clone https://github.com/hashicorp/packer-plugin-proxmox/
cd packer-plugin-proxmox/example
packer init -upgrade .
packer validate .
packer build .

Plugin and Packer version

From packer version
Packer v1.7.4

Operating system and Environment details

Debian 11, amd64

Log Fragments and crash.log files

Include appropriate log fragments. If the log is longer than a few dozen lines,
please include the URL to the gist of the log or
use the Github detailed format instead of posting it directly in the issue.

user@box:/tmp/packer-plugin-proxmox/example$ packer init -upgrade .
user@box:/tmp/packer-plugin-proxmox/example$ packer validate .
Error: Unsupported attribute

  on build.pkr.hcl line 11:
  (source code not available)

This object does not have an attribute named "foo".

Error: Unsupported attribute

  on build.pkr.hcl line 15:
  (source code not available)

This object does not have an attribute named "bar".


user@box:/tmp/packer-plugin-proxmox/example$ packer build .
Error: Unsupported attribute

  on build.pkr.hcl line 11:
  (source code not available)

This object does not have an attribute named "foo".

Error: Unsupported attribute

  on build.pkr.hcl line 15:
  (source code not available)

This object does not have an attribute named "bar".



==> Wait completed after 3 microseconds

==> Builds finished but no artifacts were created.
user@box:/tmp/packer-plugin-proxmox/example$ 

Support for UEFI boot on proxmox iso builder

This issue was originally opened by @godambrosio in hashicorp/packer#11295 and has been migrated to this repository. The original issue description is below.


Description

It will be good to have the option to select the boot type for the created vm.
The possible values are: OVMF (UEFI) and SeaBIOS.

Use Case(s)

I want to deploy a Windows vm that needs to have the same configuration as the production for validation propose and the unattended file to install it needs a UEFI bios type.

Add support for "TPM State" option for system

Description

Allow to set the "TPM" flag with version and storage if enable, when building images using this plugin. The version is by default "v2.0" but can be "v1.2".

Use Case(s)

Enabling this option allow user to get access to Windows11 VM on proxmox, since it require TPM to be installed.

Potential configuration

"os": "win11",
"machine": "q35",
"bios": "ovmf",
"efidisk": "local",
"tpm": true,
"tpm_storage": "local"

tpm_version: "v1.2" if needed but staying on v2.0 by default.

Potential References

Proxmox documentation (section 10.2.11) : https://pve.proxmox.com/pve-docs/pve-admin-guide.html#qm_virtual_machines_settings
It looks like qm set <vmid> -tpmstate0 <storage>:1,version=<version> currently to set TPM on proxmox.

Any planned date for release?

Thank you for your afford & project!

I would like to ask regarding planned date for next release. Last release is dated by last year and there are a lot of unreleased features. I will appreciate any information about release plans.

With best wishes, Michael.

Cannot eject ISO from cdrom drive, ide2 is not present, or not a cdrom media

Overview of the Issue

At the end of every build, packer errors out

Reproduction Steps

Simply running packer build as following:

packer build -only proxmox -var-file="./secrets.json" -var proxmox_node_name=${2} --on-error=abort ${1}

If I don't add --on-error=abort, packer will automatically delete the template.

Plugin and Packer version

From packer version
Packer v1.7.9 (I get the same error with version 1.8.0. I cannot try a higher version because of the qcow2 bug (#92)

Simplified Packer Buildfile

{
  "builders": [
    {
      "type": "proxmox",
      "proxmox_url": "https://{{ user `proxmox_host` }}:8006/api2/json",
      "username": "{{ user `proxmox_username` }}",
      "token": "{{ user `proxmox_token` }}",
      "node": "{{ user `proxmox_node_name` }}",
      "ssh_password": "{{ user `ssh_password` }}",
      "ssh_timeout": "30m",
      "ssh_username": "{{ user `ssh_username` }}",
      "template_name": "{{ user `template_name` }}",
      "template_description": "{{ user `template_description` }}",
      "sockets": 1,
      "cores": 2,
      "memory": 6144,
      "disks": [
        {
          "type": "scsi",
          "disk_size": "10G",
          "format": "qcow2",
          "storage_pool": "local-lvm",
          "storage_pool_type": "lvm-thin",
          "cache_mode": "none",
          "io_thread": "false"
        }
      ],
      "network_adapters": [
        {
          "bridge": "vmbr0",
          "model": "virtio"
        }
      ],
      "os": "l26",
      "unmount_iso": true,
      "cloud_init": true,
      "cloud_init_storage_pool": "cloudinit",
      "http_directory": "http",
      "http_interface": "ens160",
      "http_port_max": 8039,
      "http_port_min": 8039,
      "insecure_skip_tls_verify": false,
      "iso_checksum": "f8e3086f3cea0fb3fefb29937ab5ed9d19e767079633960ccb50e76153effc98",
      "iso_file": "nfs:iso/ubuntu-22.04-live-server-amd64.iso",
      "boot_wait": "4s",
      "boot_command": [
        "<e><bs><down><down><down>",
	"<right><right><right><right><right><right><right><right><right><right><right><right><right><right><right><right><right><right><right><right><right><right><right>",
        "<spacebar>",
        "ip={{ user `vm_ip` }}::{{ user `vm_gateway` }}:{{ user `vm_netmask` }}::::{{ user `vm_dns` }} ",
        "autoinstall 'ds=nocloud-net;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/' ",
        "<F10>"
      ]
    },
[...]

Operating system and Environment details

I'm running this on Ubuntu 20.04.4 . I've tested it on Proxmox 7.2-4 and 6.4-14 and I experience the same behaviour.

Log Fragments and crash.log files

2022/07/06 19:44:49 [INFO] (telemetry) ending ansible
2022/07/06 19:44:49 packer-provisioner-ansible plugin: shutting down the SSH proxy
==> proxmox: Stopping VM
==> proxmox: Converting VM to template
2022/07/06 19:44:54 packer-builder-proxmox plugin: template_id: 110
==> proxmox: Adding a cloud-init cdrom in storage pool cloudinit
==> proxmox: Cannot eject ISO from cdrom drive, ide2 is not present, or not a cdrom media
==> proxmox: Cannot eject ISO from cdrom drive, ide2 is not present, or not a cdrom media
==> proxmox: Step "stepFinalizeISOTemplate" failed, aborting...
==> proxmox: aborted: skipping cleanup of step "stepSuccess"
==> proxmox: aborted: skipping cleanup of step "stepFinalizeTemplateConfig"
==> proxmox: aborted: skipping cleanup of step "stepConvertToTemplate"
==> proxmox: aborted: skipping cleanup of step "StepCleanupTempKeys"
==> proxmox: aborted: skipping cleanup of step "StepProvision"
==> proxmox: aborted: skipping cleanup of step "StepConnect"
==> proxmox: aborted: skipping cleanup of step "stepTypeBootCommand"
==> proxmox: aborted: skipping cleanup of step "StepHTTPServer"
2022/07/06 19:44:57 [INFO] (telemetry) ending proxmox
==> Wait completed after 10 minutes 38 seconds
2022/07/06 19:44:57 machine readable: error-count []string{"1"}
==> proxmox: aborted: skipping cleanup of step "stepStartVM"
==> proxmox: aborted: skipping cleanup of step "stepUploadAdditionalISOs"
==> proxmox: aborted: skipping cleanup of step "stepUploadISO"
==> proxmox: aborted: skipping cleanup of step "StepDownload"
==> Some builds didn't complete successfully and had errors:
2022/07/06 19:44:57 machine readable: proxmox,error []string{"Cannot eject ISO from cdrom drive, ide2 is not present, or not a cdrom media"}
==> Builds finished but no artifacts were created.
2022/07/06 19:44:57 [INFO] (telemetry) Finalizing.
Build 'proxmox' errored after 10 minutes 38 seconds: Cannot eject ISO from cdrom drive, ide2 is not present, or not a cdrom media

==> Wait completed after 10 minutes 38 seconds

==> Some builds didn't complete successfully and had errors:
--> proxmox: Cannot eject ISO from cdrom drive, ide2 is not present, or not a cdrom media

==> Builds finished but no artifacts were created.
2022/07/06 19:44:57 waiting for all plugin processes to complete...
2022/07/06 19:44:57 /usr/bin/packer: plugin process exited
2022/07/06 19:44:57 /usr/bin/packer: plugin process exited

The template is created ok apart from that error, I just need to manually eject the CD-ROM, which is a cdrom and is ide2, so I'm not sure what causes this error.

[Proxmox-clone] add cloud-init config

This issue was originally opened by @RemiDesgrange as hashicorp/packer#10251. It was migrated here as a result of the Packer plugin split. The original body of the issue is below.


Community Note

Please vote on this issue by adding a ๐Ÿ‘ reaction to the original issue to help the community and maintainers prioritize this request.
Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request.
If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Description

Proxmox clone could have some key to setup cloud-init (user, ssh key etc...)

Use Case(s)

Being able to override cloud-init base template we inherit from.

Potential configuration

"cloud_init": {
  "user": "user",
  "password": "pass",
  "ssh_keys": "XXXX"
  "ip_config": "ip=dhcp",
  "dns_domain": "example.com",
  "dns_servers": "1.1.1.1"
}

Allow adding serial sockets to template

Description

We can add "serial0" as the vga display type, but as far as I can tell there isn't any way to create serial0 in packer.

Use Case(s)

This would allow configurations of serial ports for the template. Proxmox allows port 0-3 it seems.

Potential configuration

serial_port [0, 1, 3]

Potential References

Proxmox has a page about Serial Terminal here: https://pve.proxmox.com/wiki/Serial_Terminal

Ansible provisionner try to connect to localhost

Overview of the Issue

When I specify a an ansible provisionner :

build {
  name = "test_template"
  sources = [
    "sources.proxmox-iso.debian-tmpl",
  ]
  provisioner "ansible" {
    playbook_file = "playbooks/debian-tmpl.yml"
    user = "reachable_user"
  }
}

The process work great until the ansible part where ansible try to connect to localhost instead of the server. The server gets it's address and has the qemu-guest-agent active, I can see the IP in the proxmox webUI.

Reproduction Steps

  • Create a minimal packer build with an ansible playbook
  • Run it.

Plugin and Packer version

Packer 1.7.4

Simplified Packer Buildfile

build {
  name = "debian_template"
  sources = [
    "sources.proxmox-iso.debian-template",
  ]
  provisioner "ansible" {
    playbook_file = "playbooks/debian-template.yml"
    user = "reachable_user"
  }
}

Source:

source "proxmox-iso" "debian-template" {
  proxmox_url              = "${var.proxmox_hostname}/api2/json"
  insecure_skip_tls_verify = false
  username                 = var.proxmox_username
  password                 = var.proxmox_password
  node                     = var.proxmox_node_name

  vm_name              = "debian-11-packer-${var.template_name}"
  template_name        = "debian-11-template-${var.template_name}"
  template_description = "Template ready to be terraformed."

  memory = 4096
  cores  = 8
  os     = "l26"

  network_adapters {
    model  = "virtio"
    bridge = "vmbr1"
  }
  qemu_agent              = true
  cloud_init              = true
  cloud_init_storage_pool = "local-lvm"
  scsi_controller         = "virtio-scsi-single"
  disks {
    type              = "virtio"
    io_thread         = true
    disk_size         = 8
    storage_pool      = "local-lvm"
    storage_pool_type = "lvm"
    format            = "raw"
  }

  iso_file         = var.iso_file
  iso_storage_pool = "local-lvm"
  iso_checksum     = var.iso_checksum

  ssh_username = var.ssh_username
  ssh_password = var.ssh_password
  ssh_timeout  = "30m"
  boot_wait    = "4s"
  unmount_iso  = true
  boot_command = [
    "<esc><wait>",
    "auto ",
    "url=${var.user_data_server}preseed.cfg ",
    "<enter><wait>"
  ]

  http_directory = "http"
}

Operating system and Environment details

Arch linux for the client

Log Fragments and crash.log files

==> debian_template.proxmox-iso.debian-practice: Connected to SSH!
==> debian_template.proxmox-iso.debian-practice: Provisioning with Ansible...
    debian_template.proxmox-iso.debian-practice: Setting up proxy adapter for Ansible....
==> debian_template.proxmox-iso.debian-practice: Executing Ansible: ansible-playbook -e packer_build_name="debian-template" -e packer_builder_type=proxmox-iso -e packer_http_addr=192.168.1.100:8873 --ssh-extra-args '-o IdentitiesOnly=yes' -e ansible_ssh_private_key_file=/tmp/ansible-key589778536 -i /tmp/packer-provisioner-ansible3468307636 /home/remi/Documents/packer/playbooks/debian-templaye.yml
    student_debian_template.proxmox-iso.debian-practice:  ______________________
    student_debian_template.proxmox-iso.debian-practice: < PLAY [Minimum setup] >
    student_debian_template.proxmox-iso.debian-practice:  ----------------------
    student_debian_template.proxmox-iso.debian-practice:         \   ^__^
    student_debian_template.proxmox-iso.debian-practice:          \  (oo)\_______
    student_debian_template.proxmox-iso.debian-practice:             (__)\       )\/\
    student_debian_template.proxmox-iso.debian-practice:                 ||----w |
    student_debian_template.proxmox-iso.debian-practice:                 ||     ||
    student_debian_template.proxmox-iso.debian-practice:
    student_debian_template.proxmox-iso.debian-practice:  ________________________
    student_debian_template.proxmox-iso.debian-practice: < TASK [Gathering Facts] >
    student_debian_template.proxmox-iso.debian-practice:  ------------------------
    student_debian_template.proxmox-iso.debian-practice:         \   ^__^
    student_debian_template.proxmox-iso.debian-practice:          \  (oo)\_______
    student_debian_template.proxmox-iso.debian-practice:             (__)\       )\/\
    student_debian_template.proxmox-iso.debian-practice:                 ||----w |
    student_debian_template.proxmox-iso.debian-practice:                 ||     ||
    student_debian_template.proxmox-iso.debian-practice:
==> student_debian_template.proxmox-iso.debian-practice: failed to handshake
    student_debian_template.proxmox-iso.debian-practice: fatal: [default]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: Unable to negotiate with 127.0.0.1 port 39235: no matching host key type found. Their offer: ssh-rsa", "unreachable": true}

There is one thing that bothers me. It's the "ssh-rsa". the ssh key used is an ed25519 key, I have both an ed25519 key and an rsa key but it doesn't seem to work too.

Feature Request - Choose an existing VM template for Proxmox Builder

This issue was originally opened by @vikas027 as hashicorp/packer#7873. It was migrated here as a result of the Packer plugin split. The original body of the issue is below.


In Vagrant builder, we can choose a source_path to use an existing image. I could not find anything with proxmox builder. Can you please take this is as a feature request?

I am buzzing @carlpett as it looks like other feature Proxmox feature requests are also with him :)

Thanks,
Vikas

Packer Crash

This issue was originally opened by @roanutil in hashicorp/packer#11544 and has been migrated to this repository. The original issue description is below.


When filing a bug, please include the following headings if possible. Any
example text in this template can be deleted.

Overview of the Issue

While running a build for a Debian template with the proxmox plugin, Packer crashed.

FYI, I'm brand new to Packer so I very well may be doing something insane that is breaking it.

Reproduction Steps

Init, format, validate, and build repo
https://github.com/roanutil/packer-pihole

Packer version

1.7.9

Simplified Packer Template

https://github.com/roanutil/packer-pihole/blob/main/debian-pihole.json.pkr.hcl

Operating system and Environment details

Local: MacOS 12.3 Beta on ARM
Proxmox Host: Intel Xeon - D 2xxx running Proxmox 7.1-10

Log Fragments and crash.log files

https://github.com/roanutil/packer-pihole/blob/crash-debug/crash.log

overwrite existing template image.

I'm trying to make a repeatable pipeline and get packer to overwrite the image I'm making if its already exist. I can do this on the VMware-iso builder with applying -force when building templates. Is there a option for this in the proxmox builder? When I try to build the vm again it complains about the vmid already existing.

Error creating VM: Error creating VM: 500 unable to create VM 100 - VM 100 already exists.

I would like to be able to overwrite to build templates with newly installed updates and so on...

Documented variables `machine` & `efidisk` are not recognised

Overview of the Issue

Variables machine & efidisk are not recognised
Despite being documented here and here variables are not recognised by packer and crash the build if decalred.

Reproduction Steps

Build a manifest with efidisk or machine present.

Plugin and Packer version

Packer v1.7.8
packer-plugin-proxmox v1.0.3

Simplified Packer Buildfile

Gist

Operating system and Environment details

goblin@goblin-officepc:~/code/packer-windows$ lsb_release -d
Description:	Ubuntu 20.04.3 LTS

Log Fragments and crash.log files

Full log:
Gist
Errors:

 on win10x64-enterprise.pkr.hcl line 65:
 (source code not available)

An argument named "efidisk" is not expected here.

Error: Unsupported argument

 on win10x64-enterprise.pkr.hcl line 66:
 (source code not available)

Error: Unsupported argument
An argument named "machine" is not expected here.

Failing SSL-Verify throws no helpful error

When filing a bug, please include the following headings if possible. Any
example text in this template can be deleted.

Overview of the Issue

When trying to connect with an proxmox server with self-signed certificate and insecure_skip_tls_verify is not set to true the thrown error is not helpful.

Reproduction Steps

Use a proxmox server with self-signed certificate and insecure_skip_tls_verify = false.

Plugin and Packer version

From packer version:

Packer v1.8.2

packer init:

Installed plugin github.com/hashicorp/proxmox v1.0.8 in "/usr/local/bin/github.com/hashicorp/proxmox/packer-plugin-proxmox_v1.0.8_x5.0_darwin_amd64"

Simplified Packer Buildfile

https://gist.github.com/domrim/26b55d30da707ff01907cc7535283388#file-debian-bullseye-pkr-hcl

Operating system and Environment details

macOS 12.4, packer installed with homebrew

Log Fragments and crash.log files

https://gist.github.com/domrim/26b55d30da707ff01907cc7535283388#file-crash-log

VM are not deleted properly on proxmox-iso

This issue was originally opened by @ProfDrToast in hashicorp/packer#11249 and has been migrated to this repository. The original issue description is below.


Packer creates a VM and can also connect to it (both ssh and PTY), but in case of an error Packer only stops the VM and does not delete it.

My Packer config:

source "proxmox-iso" "ubuntu-2004" {
  boot_command   = ["<esc><enter><esc><enter><wait2s>", "/casper/vmlinuz ", "initrd=/casper/initrd quiet ", "autoinstall ds=nocloud-net;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ ---", "<enter>"]
  boot_wait      = "5s"
  proxmox_url    = "https://proxmox:8006/api2/json"
  password       = "password"
  username       = "root@pam"
  node           = "pve01"
  insecure_skip_tls_verify = true
  http_directory = "http"
  iso_checksum   = "sha256:f8e3086f3cea0fb3fefb29937ab5ed9d19e767079633960ccb50e76153effc98"
  iso_url        = "http://releases.ubuntu.com/20.04/ubuntu-20.04.3-live-server-amd64.iso"
  iso_storage_pool = "local"
  memory         = 1024
  ssh_password   = "ubuntu"
  ssh_timeout    = "30m"
  ssh_username   = "ubuntu"
  network_adapters {
     model  = "virtio"
     bridge = "vmbr0"
     firewall = false 
     }

}

build {
  sources = ["source.proxmox-iso.ubuntu-2004"]

  provisioner "shell" {
    inline = ["ls /"]
  }

}

Packer Version: Packer v1.7.4
Proxmox Version: 7.0-11

Logfile:

2021/09/04 10:00:30 packer-builder-proxmox-iso plugin: [DEBUG] Error getting SSH address: 500 QEMU guest agent is not running
Cancelling build after receiving interrupt
2021/09/04 10:00:35 packer-provisioner-shell plugin: Received interrupt signal (count: 1). Ignoring.
2021/09/04 10:00:35 Cancelling builder after context cancellation context canceled
2021/09/04 10:00:35 packer-builder-proxmox-iso plugin: [WARN] Interrupt detected, quitting waiting for SSH.
2021/09/04 10:00:35 packer-builder-proxmox-iso plugin: [DEBUG] SSH wait cancelled. Exiting loop.
2021/09/04 10:00:35 packer-builder-proxmox-iso plugin: Received interrupt signal (count: 1). Ignoring.
==> proxmox-iso.ubuntu-2004: Stopping VM
==> proxmox-iso.ubuntu-2004: Deleting VM
2021/09/04 10:00:37 [INFO] (telemetry) ending 
==> Wait completed after 3 minutes 53 seconds
2021/09/04 10:00:37 [INFO] (telemetry) Finalizing.
Build 'proxmox-iso.ubuntu-2004' errored after 3 minutes 53 seconds: build was cancelled

==> Wait completed after 3 minutes 53 seconds
Cleanly cancelled builds after being interrupted.
2021/09/04 10:00:37 waiting for all plugin processes to complete...
2021/09/04 10:00:37 /usr/bin/packer: plugin process exited
2021/09/04 10:00:37 /usr/bin/packer: plugin process exited

Build fails to unmount iso when finished

Overview of the Issue

When build new debian 11 template the build finishes with an error:
==> proxmox-iso.base: Cannot eject ISO from cdrom drive, ide2 is not present, or not a cdrom media

Build finishes and it is possible to unmound cdrom.

When looking in the pve gui it seems the string for the cdrom has changed and I would guess the problem is
in the file step_finalize_iso.go line 41, the function call HasSuffix has to probably be changed to Contains.

Reproduction Steps

Any build against a fully patched proxmox server

Plugin and Packer version

Packer v1.8.0

Simplified Packer Buildfile

any build against a fully patched proxmox will probably fail

Operating system and Environment details

Build: ubuntu 20.04
Poxmox: Virtual Environment 7.1-12

Log Fragments and crash.log files

2022/05/03 17:58:30 [INFO] (telemetry) ending ansible
2022/05/03 17:58:30 packer-provisioner-ansible plugin: shutting down the SSH proxy
==> proxmox-iso.base: Stopping VM
==> proxmox-iso.base: Converting VM to template
2022/05/03 17:58:32 packer-builder-proxmox-iso plugin: template_id: 10600
==> proxmox-iso.base: Cannot eject ISO from cdrom drive, ide2 is not present, or not a cdrom media
==> proxmox-iso.base: Provisioning step had errors: Running the cleanup provisioner, if present...
Build 'proxmox-iso.base' errored after 5 minutes 47 seconds: Cannot eject ISO from cdrom drive, ide2 is not present, or not a cdrom media

2022/05/03 17:58:37 [INFO] (telemetry) ending proxmox-iso.base
==> Wait completed after 5 minutes 47 seconds
2022/05/03 17:58:37 machine readable: error-count []string{"1"}
==> Some builds didn't complete successfully and had errors:
2022/05/03 17:58:37 machine readable: proxmox-iso.base,error []string{"Cannot eject ISO from cdrom drive, ide2 is not present, or not a cdrom media"}
==> Builds finished but no artifacts were created.
==> Wait completed after 5 minutes 47 seconds
2022/05/03 17:58:37 [INFO] (telemetry) Finalizing.

==> Some builds didn't complete successfully and had errors:
--> proxmox-iso.base: Cannot eject ISO from cdrom drive, ide2 is not present, or not a cdrom media

==> Builds finished but no artifacts were created.
2022/05/03 17:58:38 waiting for all plugin processes to complete...
2022/05/03 17:58:38 /usr/bin/packer: plugin process exited
2022/05/03 17:58:38 /usr/bin/packer: plugin process exited

Race condition when creating multiple VMs at once

Overview of the Issue

When declaring a build block with multiple proxmox sources, only the first source is able to be built. The first source gets the next free VM ID from Proxmox, while the next source tries to create a VM with the same ID and fails, as it already exists by now on the node.
This has also been raised in the official forum.

Reproduction Steps

See further down

Plugin and Packer version

plugin: 1.0.2
packer: v1.7.6

Simplified Packer Buildfile

Create a reproduction.pkr.hcl file with:

locals {
  ubuntu_image = "ubuntu-20.04.3-live-server-amd64.iso"
}

packer {
  required_plugins {
    proxmox = {
      version = ">= 1.0.2"
      source  = "github.com/hashicorp/proxmox"
    }
  }
}

source "proxmox" "source_1" {
  proxmox_url  = "https://<redacted_host>:8006/api2/json"
  username     = "packer@pve"
  node         = "proxmox"
  iso_file     = "local:iso/${local.ubuntu_image}"
  unmount_iso  = true
  memory       = 8192
  cores        = 4
  cpu_type     = "host"
  os           = "l26"
  boot_wait    = "5s"
  ssh_username = "test"
  ssh_password = "test"
}

source "proxmox" "source_2" {
  proxmox_url  = "https://<redacted_host>:8006/api2/json"
  username     = "packer@pve"
  node         = "proxmox"
  iso_file     = "local:iso/${local.ubuntu_image}"
  unmount_iso  = true
  memory       = 8192
  cores        = 4
  boot_wait    = "5s"
  ssh_username = "test"
  ssh_password = "test"
}

build {
  name = "reproduction"
  sources = [
    "source.proxmox.source_1",
    "source.proxmox.source_2"
  ]
}

and run with

$ PACKER_LOG=1 packer build reproduction.pkr.hcl
 ....
==> ubuntu.proxmox.source_2: Creating VM
==> ubuntu.proxmox.source_1: Creating VM
==> ubuntu.proxmox.source_1: No VM ID given, getting next free from Proxmox
==> ubuntu.proxmox.source_2: No VM ID given, getting next free from Proxmox
2021/10/29 23:24:49 [INFO] (telemetry) ending proxmox.source_2
==> ubuntu.proxmox.source_2: Error creating VM: Error creating VM: 500 unable to create VM 102 - VM 102 already exists on node 'proxmox', error status: {"data":null} (params: map[agent:1 boot: cores:4 cpu:kvm64 description:Packer ephemeral build VM hotplug: ide2:local:iso/ubuntu-20.04.3-live-server-amd64.iso,media=cdrom kvm:true memory:8192 name:packer-617c66a1-8dad-4d79-0a11-93dc1fb04393 numa:false onboot:false ostype:other scsihw:lsi sockets:1 tags: vmid:102])
Build 'ubuntu.proxmox.source_2' errored after 76 milliseconds 640 microseconds: Error creating VM: Error creating VM: 500 unable to create VM 102 - VM 102 already exists on node 'proxmox', error status: {"data":null} (params: map[agent:1 boot: cores:4 cpu:kvm64 description:Packer ephemeral build VM hotplug: ide2:local:iso/ubuntu-20.04.3-live-server-amd64.iso,media=cdrom kvm:true memory:8192 name:packer-617c66a1-8dad-4d79-0a11-93dc1fb04393 numa:false onboot:false ostype:other scsihw:lsi sockets:1 tags: vmid:102])

Operating system and Environment details

Proxmox 7.0-13
I don't think that other information should be necessary, but I'm happy to provide them if you need them :)

proxmox: Error updating template: 500 got no worker upid - start worker failed

This issue was originally opened by @dnv in hashicorp/packer#11149 and has been migrated to this repository. The original issue description is below.


Overview of the Issue

Roughly 2/3 of the time I am building my templates, the build errors out in the final stages, succesfully creating the actual template regardless, but with its "Packer ephemeral build VM" description and name intact. At first it "felt" like I got rid of the issue by adding the final sync command to the shell builder, but this was apparently transient/imaginary, as after 3-4 succesfull builds with no errors in a row I started experiencing the problem again.

I have now run the build several times in a row changing nothing in-between and sometimes I do get the error and sometimes not. Having done some additional testing I can now see that this has something to do with creating new VMs/templates and deleting them. The error does not seem to ever occur in the following scenario: 6 VMs are running, I run Packer to create a new template, it suceeeds, I delete the template and create it anew. But somewhere in the logic, there is a problem that manifests itself if you create a template, create a new VM from said template, keep it running, delete something with a lower vm_id and try creating a new template with Packer.

Packer version

Packer version: 1.7.3 [go1.16.5 linux amd64]

Simplified Packer Buildfile

https://gist.github.com/dnv/7e6778870f070b125cd6fade7f98aa33

Operating system and Environment details

Running Packer on RHEL 8.4 VM
Proxmox Virtual Environment 6.4-8

Log Fragments and crash.log files

The relevant part of the log is:

2021/07/15 18:14:20 [INFO] (telemetry) ending shell
==> proxmox: Stopping VM
==> proxmox: Converting VM to template
2021/07/15 18:14:22 packer-builder-proxmox plugin: template_id: 108
==> proxmox: Error updating template: 500 got no worker upid - start worker failed
==> proxmox: Provisioning step had errors: Running the cleanup provisioner, if present...
==> proxmox: Stopping VM
==> proxmox: Deleting VM
2021/07/15 18:14:22 [INFO] (telemetry) ending proxmox
==> Wait completed after 5 minutes 47 seconds
2021/07/15 18:14:22 machine readable: error-count []string{"1"}
==> Some builds didn't complete successfully and had errors:
2021/07/15 18:14:22 machine readable: proxmox,error []string{"Error updating template: 500 got no worker upid - start worker failed"}
==> Builds finished but no artifacts were created.
Build 'proxmox' errored after 5 minutes 47 seconds: Error updating template: 500 got no worker upid - start worker failed

==> Wait completed after 5 minutes 47 seconds

==> Some builds didn't complete successfully and had errors:
--> proxmox: Error updating template: 500 got no worker upid - start worker failed

==> Builds finished but no artifacts were created.

the windows machine stuck at reboot

Hello,
some times the Windows machine stuck at reboot phase, for example after firts step windpws install, and to move forwarde I need to reboot manualy my VM and after that packer continue
it's like proxmox can't properly shut down the machine

Thanks

Documentation enhancement: Proxmox Builder

Dear Packer Team,

Re: Your Proxmox Builder Docs (https://www.packer.io/docs/builders/proxmox.html)

It would be nice if you actually documented precisely what permissions Packer's Proxomox builder is expecting.

As you know Proxomox allows granular definition of user privileges (https://pve.proxmox.com/wiki/User_Management)

As you also know, its 2019 ... and so "principle of least privilege" is king, not "meh, just give it god rights". ;-)

TL;DR ... Does the Proxmox builder really need Sys.PowerMgmt , Sys.Console, User.Modify etc. etc. etc.

Use tablet for pointer

Hello to all,
Someone knows how to enable the Use tablet as pointer option during VM creation?
image

An argument named "cd_files" is not expected here.

When filing a bug, please include the following headings if possible. Any
example text in this template can be deleted.

Overview of the Issue

Running a packer build using the latest version of Packer and this plugin against a Proxmox VE cluster failed with the above error. From documentation and examples in the wild the following piece of HCL should be supproted:

  additional_iso_files {
    iso_storage_pool = "local"
    cd_files = ["cloudinit/*"]
    cd_label = "cidata"
    unmount = true
  }

This was added in #33

Reproduction Steps

  1. Clonse https://git.mills.io/prologic/packer-proxmox-ubuntu
  2. Follow README

Plugin and Packer version

$ packer version
Packer v1.8.0
$ packer plugins installed
/usr/local/bin/github.com/ivoronin/sshkey/packer-plugin-sshkey_v0.1.0_x5.0_darwin_amd64
/usr/local/bin/github.com/ivoronin/sshkey/packer-plugin-sshkey_v1.0.2_x5.0_darwin_amd64
/usr/local/bin/github.com/hashicorp/proxmox/packer-plugin-proxmox_v1.0.6_x5.0_darwin_amd64
/usr/local/bin/github.com/vultr/vultr/packer-plugin-vultr_v2.4.4_x5.0_darwin_amd64

Simplified Packer Buildfile

See: https://git.mills.io/prologic/packer-proxmox-ubuntu

Operating system and Environment details

OS, macOS / Darwin / Intel

Log Fragments and crash.log files

(โŽˆ |local:default)
prologic@Jamess-iMac
Thu May 26 13:52:37
~/Projects/packer-proxmox-ubuntu
 (master) 0
$ packer build -var 'proxmox_node_name=vz1' .
Error: Unsupported argument

  on sources.pkr.hcl line 50:
  (source code not available)

An argument named "cd_files" is not expected here.

Error: Unsupported argument

  on sources.pkr.hcl line 51:
  (source code not available)

An argument named "cd_label" is not expected here.



==> Wait completed after 5 microseconds

==> Builds finished but no artifacts were created.

packer creating a template in proxmox environment is giving errors.

This issue was originally opened by @AkhilaGarlapally as hashicorp/packer#11071. It was migrated here as a result of the Packer plugin split. The original body of the issue is below.


When filing a bug, please include the following headings if possible. Any
example text in this template can be deleted.

Overview of the Issue

facing error as proxmox: Error creating VM: Error creating VM: 400 Parameter verification failed., error status: {"errors":{"net0":"invalid format - unable to parse network options\n","scsi0":"invalid format - unable to parse drive options\n"},"data":null} (params: map[agent:0 boot: cores:2 cpu:kvm64 description:Packer ephemeral build VM hotplug: ide2:local:iso/CentOS-8.3.2011-x86_64-dvd1.iso,media=cdrom kvm:false memory:2048 name:packer-60be4925-9e43-cbc6-b9d2-3266279a731c net0:e1000=D2:08:62:1A:5F:E2,bridge=vmbr0,tag=10,firewall=false numa:false onboot:false ostype:l26 scsi0:vmpool:8,iothread=false scsihw:lsi sockets:1 tags: vmid:106])

Reproduction Steps

Steps to reproduce this issue

Packer version

I'm using packer 1.7.2

Simplified Packer Buildfile

I have taken the sample template from a github and have modified the variable according to our environment. Below is the input json file
"builders": [
{
"type": "proxmox",
"username": "{{user proxmox_username}}",
"password": "{{user proxmox_password}}",
"proxmox_url": "{{ user proxmox_url}}",
"insecure_skip_tls_verify": true,
"node": "{{user proxmox_node}}",
"os": "l26",
"boot_command": [
" text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg"
],
"network_adapters": [
{
"bridge": "vmbr0",
"model": "e1000",
"vlan_tag": 10
}
],
"disks": [
{
"type": "scsi",
"disk_size": "8G",
"storage_pool": "{{user proxmox_storage_pool}}",
"storage_pool_type": "{{user proxmox_storage_pool_type}}",
"format": "{{user proxmox_storage_format}}",
"cache_mode": "none"
}
],
"scsi_controller": "lsi",
"iso_file": "{{user proxmox_iso_pool}}/{{user centos_image}}",
"boot_wait": "10s",
"cores": "2",
"memory": "2048",
"http_directory": "centos7",
"ssh_username": "root",
"ssh_password": "Packer",
"ssh_port": 22,
"ssh_timeout": "15m",
"unmount_iso": true,
"template_name": "{{user template_name}}",
"template_description": "{{user template_description}}",
"qemu_agent": false,
"disable_kvm": true

}

],
"provisioners": [
{
"type": "shell",
"inline": [
"yum install -y cloud-init qemu-guest-agent cloud-utils-growpart gdisk",
"shred -u /etc/ssh/_key /etc/ssh/_key.pub",
"rm -f /var/run/utmp",
">/var/log/lastlog",
">/var/log/wtmp",
">/var/log/btmp",
"rm -rf /tmp/* /var/tmp/",
"unset HISTFILE; rm -rf /home/
/.*history /root/.*history",
"rm -f /root/*ks",
"passwd -d root",
"passwd -l root"
],
"only": ["proxmox"]
}
]
}

Operating system and Environment details

we are using proxmox 4.1 version and i'm trying to build centos

Do not upload an existing iso_url

When we set the iso_url property, the proxmox-iso builder always uploads the iso to the specified iso_storage_pool storage.

But this wastes time and wears out the storage.

This builder should only upload when the iso file does not exist at the given storage location.

Use SCSI controller for Cloud-Init

Community Note

Please vote on this issue by adding a ๐Ÿ‘ reaction to the original issue to help the community and maintainers prioritize this request.
Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request.
If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Description

Cloud-init drives should be attached to a SCSI controller instead of an IDE controller.

Use Case(s)

RHEL 8 doesn't support (some?) IDE drives anymore, causing Cloud-Init to abort while starting, since the Cloud-init drive is missing.

Potential configuration

-

Potential References

https://bugs.centos.org/view.php?id=16898

Add ipconfig[n] support for Proxmox builder

This issue was originally opened by @Weilbyte as hashicorp/packer#10169. It was migrated here as a result of the Packer plugin split. The original body of the issue is below.


Community Note

Please vote on this issue by adding a ๐Ÿ‘ reaction to the original issue to help the community and maintainers prioritize this request.
Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request.
If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Description

Add support for setting the cloud-init ipconfig setting when using the Proxmox builder. It should be found here as available config type => https://pve.proxmox.com/pve-docs/api-viewer/#/nodes/{node}/qemu/{vmid}/config

Use Case(s)

Easily setting up the VM template to use DHCP without having to mess around with the OS-specific configuration tools.

Potential configuration

For example setting v4/v6 to DHCP:

{
 "ipconfig": [
    id: 0,
    v4: "dhcp",
    v6: "dhcp"
  ]
}

Proxmox builder 400 parameter verification failed

This issue was originally opened by @alexwaibel in hashicorp/packer#11222 and has been migrated to this repository. The original issue description is below.


Overview of the Issue

I'm getting an error "400 Parameter verification failed" when trying to build a Proxmox template, but the error doesn't specify which value is invalid. The error appears to be occurring during the "stepUploadISO" step of the build. I've tried enabling the packer debug output, but have not been able to find what validation is failing. I can see from Proxmox cluster logs that the terraform user is authenticating successfully.

Reproduction Steps

export PM_PASS={YOUR_PROXMOX_PASSWORD}
PACKER_LOG=1 packer build -var proxmox_password=$PM_PASS fileserver.pkr.hcl

Packer version

Packer v1.7.4

Simplified Packer Buildfile

See this gist

Operating system and Environment details

Running Packer on Ubuntu 20.04

Log Fragments and crash.log files

See this gist

Proxmox 6, vm Debian 9, problem with the preseed.cfg file, when we get to the storage configuration it does not continue with the installation, the screen remains blue and does not continue

This issue was originally opened by @3nueves as hashicorp/packer#10403. It was migrated here as a result of the Packer plugin split. The original body of the issue is below.


When filing a bug, please include the following headings if possible. Any
example text in this template can be deleted.

Overview of the Issue

Before we start, I apologize for my English.

When the packer reaches the boot_command and uploads the preseed.cfg file this file works the problem is when we get to the step to configure the storage, at this moment the process stops and does not continue, we only see the blue screen.

Reproduction Steps

I have a 6.2-4 version of the proxmox server where I run virtual machines and I would like to have my custom ISO.

To create ISO I have two files, a configuration file and the packer file.
I launch the command from my desktop:

$ packer build -var-file = config.json debian-9.13.json
proxmox: the output will be in this color.

==> proxmox: Creating VM
==> proxmox: Starting VM
==> proxmox: starting the HTTP server on port 8902
==> proxmox: Waiting 10 seconds for boot
==> proxmox: typing boot command
==> proxmox: Waiting for SSH to be available ...

It loads the proseed.cfg file without problems and runs the whole process until it reaches the storage configuration. It stops here and does not continue, it reaches the timeout.

Packer version

From packer v1.6.5

Simplified Packer Buildfile

debian-9.13.json

{
  "builders": [
	{
	  .....
	  "disks": [
		{
			"type": "virtio",
			"disk_size": "{{ user `disk_size`}}",
			"storage_pool": "{{user `datastore`}}",
			"storage_pool_type": "{{user `datastore_type`}}"
		}
	  ],
         ......

	  "iso_file": "{{user `iso`}}",
	  "http_directory": "http",
	  "template_description": "{{ user `template_description` }}",

	  "boot_wait": "10s",
	  "boot_command": [
		"{{ user `boot_command_prefix` }}",
		"install <wait>",
		"preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg<wait>",
		"debian-installer=en_US.UTF-8 <wait>",
                "auto <wait>",
                "locale=en_US.UTF-8 <wait>",
                "kbd-chooser/method=es <wait>",
                "keyboard-configuration/xkb-keymap=es <wait>",
                "netcfg/get_hostname=node0 <wait>",
                "netcfg/get_domain=test.lan <wait>",
                "fb=false <wait>",
                "debconf/frontend=noninteractive <wait>",
                "console-setup/ask_detect=false <wait>",
                "console-keymaps-at/keymap=es <wait>",
                "grub-installer/bootdev=/dev/sda <wait>",
		"<enter><wait>"
	     ]
	  }
	],
	...
}

Vars file: config.json

{
  "template_description": "debian 9.13, generated by packer on {{ isotime \"2020-01-02T15:04:05Z\" }}",

  "hostname": "node0",
  "local_domain": "internal.test",
  "vmid": "400",
  "locale": "es_ES",
  "cores": "1",
  "sockets": "1",
  "memory": "2048",
  "disk_size": "50G",
  "datastore": "local-lvm",
  "datastore_type": "lvm",
  "iso": "local:iso/debian-9.13.0-amd64-netinst.iso",

  "boot_command_prefix": "<esc><wait>",
  "preseed_file": "preseed.cfg"
}

proseed.cfg

#Early
d-i partman/early_command string \
echo "Starting install" \
sleep 60

# Localization ----------------------------------------------------------
# d-i debian-installer/language string en
# d-i debian-installer/country string ES
# d-i debian-installer/locale string en_GB.UTF-8

# Keymap & Console ------------------------------------------------------
# d-i keyboard-configuration/xkb-keymap select es

# Network ---------------------------------------------------------------
d-i netcfg/enable boolean true
d-i netcfg/choose_interface select auto
d-i netcfg/dhcp_failed note
d-i netcfg/dhcp_options select Configure network manually

# Mirror settings ------------------------------------------------------
d-i mirror/country string manual
d-i mirror/http/hostname string ftp.es.debian.org
d-i mirror/http/directory string /debian/
d-i mirror/http/proxy string

# Root password ---------------------------------------------------------
d-i passwd/root-password password user
d-i passwd/root-password-again password pass

# user account ----------------------------------------------------------
d-i passwd/user-fullname string user1
d-i passwd/username string user1
d-i passwd/user-password password pass
d-i passwd/user-password-again password pass
d-i passwd/user-uid string 1010

# Clock and time zone setup --------------------------------------------
d-i clock-setup/utc boolean true
d-i time/zone string Europe/Madrid
d-i clock-setup/ntp boolean true

# Partitioning ----------------------------------------------------------
d-i partman-auto/disk string /dev/sda
d-i partman-auto/method string lvm
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-auto/expert_recipe string                         \
      boot-root ::                                                                         \
              40 300 300 ext4                                                             \
                      $primary{ }                             \
                      $bootable{ }                            \
                      method{ format } format{ }              \
                      use_filesystem{ } filesystem{ ext4 }    \
                      mountpoint{ /boot }                     \
              .                                               \
              2000 10000 100000000 ext4     \                                                        \
                      $primary{ }                             \
                      method{ lvm }               \
                      device{ /dev/sda}   \
                      vg_name{ vg-root }                     \
                .                                                       \
              2000 10000 100000000 ext4                      \
                      $lvmok{ }                               \
                      in_vg{ vg-root }             \
                      lv_name{ lv-root }     \
                      method{ format } format{ }              \
                      use_filesystem{ } filesystem{ ext4 }    \
                      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-lvm/confirm boolean true
d-i partman-lvm/confirm_nooverwrite boolean true


#  Package selection -------------------------------------------------------------------
tasksel tasksel/first multiselect standard 

# Additional packages ------------------------------------------------------------------
d-i pkgsel/include string console-setup console-data openssh-server

# Custom config ------------------------------------------------------------------------
d-i preseed/late_command string  \
cp install.sh /target/root/install.sh; \
in-target apt update -y; \
in-target apt install -y sudo; \
in-target usermod -aG sudo kub; \
in-target chmod +x /root/install.sh; \
in-target  sh -c /root/install.sh;

# Boot loader installation ----------------------------------------------------
# Install grub in the first device (assuming it is not a USB stick)
d-i grub-installer/only_debian boolean true
d-i grub-installer/with_other_os boolean true
d-i grub-installer/bootdev  string default

# Finishing up the installation -----------------------------------------------
d-i finish-install/reboot_in_progress note

Operating system and Environment details

proxmox:
pve-manager/6.2-4/9824574a
kernel version: Linux 5.4.34-1-pve hashicorp/packer#1 SMP PVE 5.4.34-2

ISO:
debian-9.13.0-amd64-netinst.iso

Log Fragments and crash.log files

$ packer build -debug -var-file=config.json debian-9.13.json

==> proxmox: Pausing after run of step 'StepDownload'. Press enter to continue.
==> proxmox: Pausing after run of step 'stepUploadISO'. Press enter to continue.
==> proxmox: Pausing after run of step 'stepUploadAdditionalISOs'. Press enter to continue.
==> proxmox: Creating VM
==> proxmox: Starting VM
==> proxmox: Pausing after run of step 'stepStartVM'. Press enter to continue.
==> proxmox: Starting HTTP server on port 8605
==> proxmox: Pausing after run of step 'StepHTTPServer'. Press enter to continue.
==> proxmox: Waiting 10s for boot
==> proxmox: Typing the boot command
==> proxmox: Pausing after run of step 'stepTypeBootCommand'. Press enter to continue.
==> proxmox: Waiting for SSH to become available...
Cancelling build after receiving interrupt
==> proxmox: Pausing before cleanup of step 'stepTypeBootCommand'. Press enter to continue.
==> proxmox: Pausing before cleanup of step 'StepHTTPServer'. Press enter to continue.
==> proxmox: Pausing before cleanup of step 'stepStartVM'. Press enter to continue.
==> proxmox: Stopping VM
==> proxmox: Deleting VM
==> proxmox: Pausing before cleanup of step 'stepUploadAdditionalISOs'. Press enter to continue.
==> proxmox: Pausing before cleanup of step 'stepUploadISO'. Press enter to continue.
==> proxmox: Pausing before cleanup of step 'StepDownload'. Press enter to continue.
Build 'proxmox' errored after 2 minutes 52 seconds: build was cancelled

qemu_agent defaulting to false, even though default should be true

Overview of the Issue

When creating a VM using Proxmox ISO Builder, if qemu_agent is left unset, the expected result is for it to default to true. However, it is defaulting to false. Tests, pass, however they should fail.
https://www.packer.io/docs/builders/proxmox/iso#qemu_agent

Reproduction Steps

Plugin and Packer version

From packer version
1.7.2

Simplified Packer Buildfile

From Proxmox ISO builder test.

{
  "builders": [
    {
      "type": "proxmox-iso",
      "proxmox_url": "https://my-proxmox.my-domain:8006/api2/json",
      "insecure_skip_tls_verify": true,
      "username": "apiuser@pve",
      "password": "supersecret",

      "node": "my-proxmox",
      "network_adapters": [
        {
          "bridge": "vmbr0"
        }
      ],
      "disks": [
        {
          "type": "scsi",
          "disk_size": "5G",
          "storage_pool": "local-lvm",
          "storage_pool_type": "lvm"
        }
      ],

      "iso_file": "local:iso/Fedora-Server-dvd-x86_64-29-1.2.iso",
      "http_directory":"config",
      "boot_wait": "10s",
      "boot_command": [
        "<up><tab> ip=dhcp inst.cmdline inst.ks=http://{{.HTTPIP}}:{{.HTTPPort}}/ks.cfg<enter>"
      ],

      "ssh_username": "root",
      "ssh_timeout": "15m",
      "ssh_password": "packer",

      "unmount_iso": true,
      "template_name": "fedora-29",
      "template_description": "Fedora 29-1.2, generated on {{ isotime \"2006-01-02T15:04:05Z\" }}"
    }
  ]
}

Operating system and Environment details

Docker Container
hashicorp/packer:latest

Documentation does not take account all possible arguments for both builders

Overview of the Issue

There are arguments which are common to proxmox-iso and proxmox-clone but they are documented only in one of the two builders article.
The clarification would help users to take full notion of the possibilities when building

Reproduction Steps

Build using the numbered arguments below. The build will work normally.

Plugin and Packer version

Packer v1.7.10
packer-plugin-proxmox v1.0.4

Simplified Packer Buildfile

If the file is longer than a few dozen lines, please include the URL to the
gist of the log or use the Github detailed
format

instead of posting it directly in the issue.

source "proxmox-clone" "autogenerated" {
  clone_vm     = "ubuntu-2004"
  ssh_username = "ubuntu"
  insecure_skip_tls_verify = true
#####  non-documented arguments
  qemu_agent           = false
  cloud_init           = false
  cloud_init_storage_pool = "local-zfs"
  additional_iso_files {
    unmount          = true
    device           = "ide1"
    iso_storage_pool = "local"
    iso_file         = "local:iso/systemrescue-9.00-amd64.iso"
  }
  http_interface = "wlp2s0"  
  vm_interface   = "eth0"
  # http_directory = "dir"
  http_content   = {
    "foo/bar" = "baz"
  }
  http_port_min  = 8000
  http_port_max  = 8000

  disks {
    disk_size         = "1G"
    format            = "raw"
    storage_pool      = "local-zfs"
    storage_pool_type = "zfspool"
    type              = "scsi"
    io_thread         = "true"
  }
  boot_key_interval = "10m"
######
  # other usual options
}

Operating system and Environment details

$ lsb_release -d
Description:	Ubuntu 20.04.4 LTS
$ uname -m
x86_64

Log Fragments and crash.log files

(none)

Unable to upload ISO with API user

Overview of the Issue

When using an API token and either the cd_files and/or cd_content options in an additional_iso_files block like below, or the iso_url option, the upload fails with the error Post "https://<hostname>:8006/api2/json/nodes/<node>/storage/resources/upload": write tcp 192.168.5.71:51734->192.168.1.10:8006: use of closed network connection. I am able to manually upload an ISO without issue, and I've even tried assigning the API token I used full Administrator, but it continues to fail with this error. I can also upload an ISO using a username and password rather than an API token.

additional_iso_files {
    device   = "ide3"

    # Generate image with unattended installer
    cd_files = [
        "./autounattend.xml"
    ]
    cd_label = "autounattend"

    iso_storage_pool = "resources"
    unmount          = true
}
    iso_url          = "./autounattend.iso"
    iso_checksum     = "sha1:539d87c4b66ea7bc9770f103e6e7952a97b56008"
    iso_storage_pool = "resources"

I'm also not positive that this report should be here and not proxmox-api-go, not sure where the problem lies.

Reproduction Steps

Steps to reproduce this issue

  1. Use either the cd_files block above or create a new .iso file and specify it with iso_url
  2. Create a new API token and give it enough permissions to work with Packer (I even tested with Administrator)
  3. Run Packer
  4. The ISO will immediately fail to upload with the Packer error use of closed network connection
  5. Check the pveproxy access logs on your Proxmox server, they will show a 403 error and that the request was unauthenticated

Plugin and Packer version

From packer version:

Packer v1.8.0
/home/<username>/.config/packer/plugins/github.com/hashicorp/proxmox/packer-plugin-proxmox_v1.0.5_x5.0_linux_amd64

Simplified Packer Buildfile

Buildfile

Operating system and Environment details

OS, Architecture, and any other information you can provide about the
environment:

  • Packer is running in LXC under Proxmox (uname -a: Linux <removed> 5.13.19-6-pve #1 SMP PVE 5.13.19-14 (Thu, 10 Mar 2022 16:24:52 +0100) x86_64 x86_64 x86_64 GNU/Linux)
  • The Packer client and Proxmox server are on different subnets, I had to add a firewall allow so that it could be accessed on :8006
  • I also proxy the Proxmox interface using Nginx, but the same issue occurred when I tried with that
  • The API token uses privilege separation

Log Fragments and crash.log files

Relevant log from /var/log/pveproxy/access.log:

::ffff:192.168.5.71 - - [12/04/2022:16:01:19 -0700] "POST /api2/json/nodes/<node>/storage/resources/upload HTTP/1.1" 403 -

This error seems to suggest that Packer isn't sending the API credentials, since authenticated requests normally start with ::ffff:127.0.0.1 - root@pam. So the PVE API would simply be rejecting and closing the POST request, while at the same time Packer tries to upload the file, resulting in the use of closed network connection.

proxmox-clone: "task_timeout is not expected here"

Overview of the Issue

According to the release commit for v1.0.2, proxmox-clone should support task_timeout as a build argument. However, Packer complains that it does not expect the argument.

Reproduction Steps

Given a file main.pkr.hcl:

packer {
  required_plugins {
    proxmox = {
      version = ">= 1.0.2"
      source  = "github.com/hashicorp/proxmox"
    }
  }
}

source "proxmox-clone" "main" {
  clone_vm     = "some_vm_template"
  node         = "some_node"
  password     = "some_password"
  proxmox_url  = "some_proxmox_url"
  task_timeout = "10m"
  username     = "some_username"
}

build {
  sources = ["source.proxmox-clone.main"]
}

Run packer init . && packer validate ., and observe the following error:

Error: Unsupported argument

  on main.pkr.hcl line 15:
  (source code not available)

An argument named "task_timeout" is not expected here.

Plugin and Packer version

Via packer version:

Packer v1.7.4

Plugin version scoped in the build file above, and also confirmed version number in local cache as ${HOME}}/.packer.d/plugins/github.com/hashicorp/proxmox/packer-plugin-proxmox_v1.0.2_x5.0_linux_amd64.

Operating system and Environment details

OS: Manjaro Linux
Architecture: x86_64

Log Fragments and crash.log files

PACKER_LOG=1 packer validate . yields:

2021/09/07 23:49:33 [INFO] Packer version: 1.7.4 [go1.16.6 linux amd64]                                                                                                                                                         [0/513]
2021/09/07 23:49:33 [TRACE] discovering plugins in /usr/bin                                                                                                                                                                            
2021/09/07 23:49:33 [TRACE] discovering plugins in /home/ryan/.packer.d/plugins
2021/09/07 23:49:33 [TRACE] discovering plugins in .
2021/09/07 23:49:33 [INFO] PACKER_CONFIG env var not set; checking the default config file path
2021/09/07 23:49:33 [INFO] PACKER_CONFIG env var set; attempting to open config file: /home/ryan/.packerconfig
2021/09/07 23:49:33 [WARN] Config file doesn't exist: /home/ryan/.packerconfig
2021/09/07 23:49:33 [INFO] Setting cache directory: /home/ryan/repos/opensourcecorp/ymir/reprex/packer_cache
2021/09/07 23:49:33 [TRACE] listing potential installations for "github.com/hashicorp/proxmox" that match ">= 1.0.2". plugingetter.ListInstallationsOptions{FromFolders:[]string{"/usr/bin/packer", ".", "/home/ryan/.packer.d/plugins"
}, BinaryInstallationOptions:plugingetter.BinaryInstallationOptions{APIVersionMajor:"5", APIVersionMinor:"0", OS:"linux", ARCH:"amd64", Ext:"", Checksummers:[]plugingetter.Checksummer{plugingetter.Checksummer{Type:"sha256", Hash:(*
sha256.digest)(0xc00026c100)}}}}
2021/09/07 23:49:33 [TRACE] Found the following "github.com/hashicorp/proxmox" installations: [{/home/ryan/.packer.d/plugins/github.com/hashicorp/proxmox/packer-plugin-proxmox_v1.0.2_x5.0_linux_amd64 v1.0.2}]
2021/09/07 23:49:33 [INFO] found external [-packer-default-plugin-name- proxmox-clone proxmox-iso] builders from proxmox plugin
2021/09/07 23:49:33 [TRACE] Starting internal plugin packer-builder-proxmox-clone
2021/09/07 23:49:33 Starting plugin: /usr/bin/packer []string{"/usr/bin/packer", "plugin", "packer-builder-proxmox-clone"}
2021/09/07 23:49:33 Waiting for RPC address for: /usr/bin/packer
2021/09/07 23:49:34 packer-builder-proxmox-clone plugin: [INFO] Packer version: 1.7.4 [go1.16.6 linux amd64]
2021/09/07 23:49:34 packer-builder-proxmox-clone plugin: [INFO] PACKER_CONFIG env var not set; checking the default config file path
2021/09/07 23:49:34 packer-builder-proxmox-clone plugin: [INFO] PACKER_CONFIG env var set; attempting to open config file: /home/ryan/.packerconfig
2021/09/07 23:49:34 packer-builder-proxmox-clone plugin: [WARN] Config file doesn't exist: /home/ryan/.packerconfig 
2021/09/07 23:49:34 packer-builder-proxmox-clone plugin: [INFO] Setting cache directory: /home/ryan/repos/opensourcecorp/ymir/reprex/packer_cache
2021/09/07 23:49:34 packer-builder-proxmox-clone plugin: args: []string{"packer-builder-proxmox-clone"}
2021/09/07 23:49:34 packer-builder-proxmox-clone plugin: Plugin address: unix /tmp/packer-plugin555706750
2021/09/07 23:49:34 packer-builder-proxmox-clone plugin: Waiting for connection...
2021/09/07 23:49:34 Received unix RPC address for /usr/bin/packer: addr is /tmp/packer-plugin555706750
2021/09/07 23:49:34 packer-builder-proxmox-clone plugin: Serving a plugin connection...

  on main.pkr.hcl line 15:
  (source code not available)

Error: Unsupported argument
An argument named "task_timeout" is not expected here.


2021/09/07 23:49:34 [INFO] (telemetry) Finalizing.
  on main.pkr.hcl line 15:
  (source code not available)

An argument named "task_timeout" is not expected here.


2021/09/07 23:49:34 waiting for all plugin processes to complete...
2021/09/07 23:49:34 /usr/bin/packer: plugin process exited

VM stuck at cloud-init while running "init-local"

Overview of the Issue

I was following along this video to create a ubuntu VM template with cloud-init for proxmox, I copied the packer file and ran it but once the VM starts and the boot command is entered it doesnt proceed further than some cloud-init process

image

I even tried changing the ISO to 22.04 and used this config

image

It gets stuck at the cloud-init stage again

Reproduction Steps

Ran packer on the config provided in both of these sources

Plugin and Packer version

packer version 1.8
Plugin proxmox

Simplified Packer Buildfile

https://github.com/justin-p/packer-proxmox-ubuntu2004/blob/main/ubuntu2004.pkr.hcl
https://github.com/aerialls/madalynn-packer/blob/master/ubuntu-22.04/ubuntu.json
https://github.com/xcad2k/boilerplates/tree/main/packer/proxmox/ubuntu-server-focal-docker

Operating system and Environment details

Proxmox Virtual Environment 6.4-4

Log Fragments and crash.log files

image

Add support for "Discard" option for disks

Description

Allow to set the "Discard" option to the VM disk when building images using this plugin.

Use Case(s)

Enabling this option can help to reduce template size by passing through the TRIM commands to the underlying storage backend (i.e after using fstrim command inside the guest) and therefore unallocate unused blocks (useful when using lvm-thin backend).

I usually use the fstrim command at the end of the build to try to reduce the template size, it works nicely using the qemu plugin but this doesn't work well on Proxmox because the discard option is disabled by default.

Potential configuration

disks {
    disk_size         = "32G"
    type              = "scsi"
    format            = "raw"
    discard           = true
    storage_pool      = "lvmp1"
    storage_pool_type = "lvm-thin"
}

Potential References

Proxmox documentation (section Trim/Discard): https://pve.proxmox.com/pve-docs/pve-admin-guide.html#chapter_virtual_machines

Proxmox Builder errors when TFA activated for user: "Missing TFA code"

This issue was originally opened by @rsik as hashicorp/packer#10923. It was migrated here as a result of the Packer plugin split. The original body of the issue is below.


Overview of the Issue

proxmox: output will be in this color.

Build 'proxmox' errored after 185 milliseconds 776 microseconds: Missing TFA code

==> Wait completed after 186 milliseconds 121 microseconds

==> Some builds didn't complete successfully and had errors:
--> proxmox: Missing TFA code

==> Builds finished but no artifacts were created.

Cannot authenticate with builder with username/password + TOTP/MFA. As seen above, it catches the correct error but I do not seem to see any mention in the docs: https://www.packer.io/docs/builders/proxmox/iso

I am curious if this is supported, but not documented? If it is supported, what is the KV required?

Reproduction Steps

  1. Make sure TOTP is activated for user in Proxmox
  2. Pass username/password in packer vars
  3. Receive error in overview

Packer version

โฏ packer --version
1.7.2

unknown error Post "http://10.230.0.50:5986/wsman

When filing a bug, please include the following headings if possible. Any
example text in this template can be deleted.

Overview of the Issue

I followed the steps outlined here...

https://www.packer.io/docs/communicators/winrm

swapping administrator for my user. However when I run my code...

Reproduction Steps and Simplified Packer Buildfile

Try with my code located here: https://gist.github.com/jmmeacham/561ac0beb1615b2360509babfc08dcc8

Operating system and Environment details

Windows-10
Using proxmox, connecting in via the API from a docker container, running code.

Log Fragments and crash.log files

PACKER_LOG=1 packer build flare-10.json

2022/02/02 22:16:17 packer-builder-proxmox-clone plugin: [DEBUG] Error getting WinRM host: 500 QEMU guest agent is not running
2022/02/02 22:16:22 packer-builder-proxmox-clone plugin: [INFO] Attempting WinRM connection...
2022/02/02 22:16:22 packer-builder-proxmox-clone plugin: [DEBUG] connecting to remote shell using WinRM
2022/02/02 22:16:52 packer-builder-proxmox-clone plugin: [ERROR] connection error: unknown error Post "http://10.230.0.50:5986/wsman": dial tcp 10.230.0.50:5986: i/o timeout
2022/02/02 22:16:52 packer-builder-proxmox-clone plugin: [ERROR] WinRM connection err: unknown error Post "http://10.230.0.50:5986/wsman": dial tcp 10.230.0.50:5986: i/o timeout
2022/02/02 22:16:57 packer-builder-proxmox-clone plugin: [INFO] Attempting WinRM connection...

Plugin assigns bad ide drive to cloud-init

ideControllers := []string{"ide3", "ide2", "ide1", "ide0"}

During packer proxmox build, the install CD-ROM is installed on ide2 (which is fine). But, with cloud_init: true, the loop selects ide3 first (which proxmox 7.0-11 doesn't support).

However, if the loop were reversed to select the low ide drives first, it should select ide0.

The current workaround is to disable cloud_init: true, wait for the build to finish, open the new template, add a cloud-init cdrom by hand to ide0 or ide1.

Client default timeout needs adjustment for longer clones

I believe the default timeout period (30 sec) is being used to wait for completion of a full clone. When clones take longer than this, I'm seeing timeout errors, I'm guessing this is because my proxmox server is slower or the disks being cloned are relatively large. When not performing a full_clone, the timeout is not reached and the plugin behaves normally. Clones in my case take 90 seconds.

Here is where the default is set:

const defaultTaskTimeout = 30 * time.Second

Which eventually gets passed here where the error occurs:
https://github.com/Telmate/proxmox-api-go/blob/51bd4ae21d9a8ecdd7f040c48c240756616c7d08/proxmox/client.go#L577

Ideally I could imagine this being broken out as an explicit configuration parameter. A more expedient fix is to just increase the default timeout.

Packer v1.7.2
packer-plugin-proxmox 0.0.2

Relevant log fragment:

==> proxmox-clone.autogenerated_1: Creating VM
==> proxmox-clone.autogenerated_1: No VM ID given, getting next free from Proxmox
2021/06/06 10:32:44 packer-builder-proxmox-clone plugin: 500 can't lock file '/var/lock/qemu-server/lock-105.conf' - got timeout
==> proxmox-clone.autogenerated_1: Error creating VM: 500 can't lock file '/var/lock/qemu-server/lock-105.conf' - got timeout
2021/06/06 10:32:44 [INFO] (telemetry) ending 
==> Wait completed after 40 seconds 622 milliseconds
2021/06/06 10:32:44 machine readable: error-count []string{"1"}
==> Some builds didn't complete successfully and had errors:
2021/06/06 10:32:44 machine readable: proxmox-clone.autogenerated_1,error []string{"Error creating VM: 500 can't lock file '/var/lock/qemu-server/lock-105.conf' - got timeout"}
==> Builds finished but no artifacts were created.
2021/06/06 10:32:44 [INFO] (telemetry) Finalizing.
Build 'proxmox-clone.autogenerated_1' errored after 40 seconds 622 milliseconds: Error creating VM: 500 can't lock file '/var/lock/qemu-server/lock-105.conf' - got timeout

==> Wait completed after 40 seconds 622 milliseconds

==> Some builds didn't complete successfully and had errors:
--> proxmox-clone.autogenerated_1: Error creating VM: 500 can't lock file '/var/lock/qemu-server/lock-105.conf' - got timeout

==> Builds finished but no artifacts were created.

I'm having trouble explaining why the error occurs consistently after 40 seconds and not 30 seconds. It is possible I'm mixing up the timeout at fault here.

Implement cd_files option for proxmox builder

This issue was originally opened by @clayshek as hashicorp/packer#10613. It was migrated here as a result of the Packer plugin split. The original body of the issue is below.


Community Note

Please vote on this issue by adding a ๐Ÿ‘ reaction to the original issue to help the community and maintainers prioritize this request.
Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request.
If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Description

Would be super helpful for the Packer Proxmox builder to be able to provide functionality to include files in an additional CD drive attached to a VM during image build, or to better understand if this isn't possible for some reason. This would be similar to the same cd_files functionality recently merged for qemu, hyperv, and vmware builders in hashicorp/packer#9928.

Use Case(s)

Primary use case would be to provide a method for unattended OS installations where additional files need to be provided, and where using the network is not an option. Examples are for Ubuntu 20.04 autoinstall where cloud-init files are needed, or even Microsoft Windows for providing the AutoUnattend.xml.

An example reason for not being able to provide the config file(s) over the network is this Packer bug: github.com/hashicorp/packer/issues/9973.

proxmox-clone does not honor os argument

Overview of the Issue

proxmox-clone does not honor os argument.

Reproduction Steps

  • Setup your VM template with a specific value for os type.
  • Build a manifest with proxmox-clone invoking the template clone_vm = "your-template", and os optional argument different than the source template one.
  • You will see the source Os Type attribute not your settings one during building process. also in the final vm template.

Plugin and Packer version

Packer v1.7.10
packer-plugin-proxmox v1.0.4

Simplified Packer Buildfile

packer {
  required_plugins {
    proxmox = {
      version = ">= 1.0.4"
      source  = "github.com/hashicorp/proxmox"
    }
  }
}

variable "proxmox_token" {
  type    = string
  default = "${env("PROXMOX_TOKEN")}"
}

source "proxmox-clone" "autogenerated_1" {
  clone_vm     = "ubuntu-2004-cloudimg"
  ssh_username = "ubuntu"
  insecure_skip_tls_verify = true
  
  ssh_host             = "192.168.0.144"
  network_adapters {
    bridge = "vmbr0"
    model  = "virtio"
    mac_address = "be:ef:ca:fe:c0:fe"
  }

  node                 = "pvelab"
  proxmox_url          = "https://foo.example.net:8006/api2/json"
  template_description = "image made from cloud-init image"
  template_name        = "ubuntu-2004-scaffolding"
  token                = "${var.proxmox_token}"
  username             = "root@pam!packer-test"
  memory               = 2048
  os                   = "l26"
  scsi_controller      = "virtio-scsi-pci"
}

build {
  sources = ["source.proxmox-clone.autogenerated_1"]
  provisioner "shell" {
    inline = ["echo test", "sleep 10", "echo bye"]
  }
}

Operating system and Environment details

$ lsb_release -d
Description:	Ubuntu 20.04.4 LTS
$ uname -m
x86_64

Log Fragments and crash.log files

This are the logs from packer. From proxmox side I saw the HTTP requests and I can confirm there is no setup with ostype attribute for the VM nor the Template.

2022/02/22 19:33:08 [INFO] Packer version: 1.7.10 [go1.17.6 linux amd64]
2022/02/22 19:33:08 [TRACE] discovering plugins in /home/linuxbrew/.linuxbrew/Cellar/packer/1.7.10/libexec/bin
2022/02/22 19:33:08 [TRACE] discovering plugins in /home/user/.config/packer/plugins
2022/02/22 19:33:08 [TRACE] discovering plugins in .
2022/02/22 19:33:08 [DEBUG] Discovered plugin: custom = /home/user/Doing/2022_packer_proxmox/sandbox_packer_proxmox/packer-plugin-custom
2022/02/22 19:33:08 [INFO] found external [-packer-default-plugin-name- proxmox-clone proxmox-iso] builders from custom plugin
2022/02/22 19:33:08 [TRACE] discovering plugins in 
2022/02/22 19:33:08 [DEBUG] Discovered plugin: custom = /home/user/Doing/2022_packer_proxmox/sandbox_packer_proxmox/packer-plugin-custom
2022/02/22 19:33:08 [INFO] found external [-packer-default-plugin-name- proxmox-clone proxmox-iso] builders from custom plugin
2022/02/22 19:33:08 [TRACE] discovering plugins in /home/linuxbrew/.linuxbrew/bin
2022/02/22 19:33:08 [INFO] PACKER_CONFIG env var not set; checking the default config file path
2022/02/22 19:33:08 [INFO] PACKER_CONFIG env var set; attempting to open config file: /home/user/.packerconfig
2022/02/22 19:33:08 [WARN] Config file doesn't exist: /home/user/.packerconfig
2022/02/22 19:33:08 [INFO] Setting cache directory: /home/user/.cache/packer
2022/02/22 19:33:08 [TRACE] listing potential installations for "github.com/hashicorp/proxmox" that match ">= 1.0.4". plugingetter.ListInstallationsOptions{FromFolders:[]string{"/home/linuxbrew/.linuxbrew/Cellar/packer/1.7.10/libexec/bin/packer", ".", "/home/user/.config/packer/plugins", "", "/home/linuxbrew/.linuxbrew/bin"}, BinaryInstallationOptions:plugingetter.BinaryInstallationOptions{APIVersionMajor:"5", APIVersionMinor:"0", OS:"linux", ARCH:"amd64", Ext:"", Checksummers:[]plugingetter.Checksummer{plugingetter.Checksummer{Type:"sha256", Hash:(*sha256.digest)(0xc00018a100)}}}}
2022/02/22 19:33:08 [TRACE] Found the following "github.com/hashicorp/proxmox" installations: [{/home/linuxbrew/.linuxbrew/bin/github.com/hashicorp/proxmox/packer-plugin-proxmox_v1.0.4_x5.0_linux_amd64 v1.0.4}]
2022/02/22 19:33:08 [INFO] found external [-packer-default-plugin-name- proxmox-clone proxmox-iso] builders from proxmox plugin
2022/02/22 19:33:08 [TRACE] validateValue: not active for proxmox_token, so skipping
2022/02/22 19:33:08 [TRACE] validateValue: not active for proxmox_url, so skipping
2022/02/22 19:33:08 [TRACE] validateValue: not active for proxmox_username, so skipping
2022/02/22 19:33:08 [TRACE] validateValue: not active for proxmox_node, so skipping
2022/02/22 19:33:08 [TRACE] Starting internal plugin packer-builder-proxmox-clone
2022/02/22 19:33:08 Starting plugin: /home/linuxbrew/.linuxbrew/Cellar/packer/1.7.10/libexec/bin/packer []string{"/home/linuxbrew/.linuxbrew/Cellar/packer/1.7.10/libexec/bin/packer", "plugin", "packer-builder-proxmox-clone"}
2022/02/22 19:33:08 Waiting for RPC address for: /home/linuxbrew/.linuxbrew/Cellar/packer/1.7.10/libexec/bin/packer
2022/02/22 19:33:08 packer-builder-proxmox-clone plugin: [INFO] Packer version: 1.7.10 [go1.17.6 linux amd64]
2022/02/22 19:33:08 packer-builder-proxmox-clone plugin: [INFO] PACKER_CONFIG env var not set; checking the default config file path
2022/02/22 19:33:08 packer-builder-proxmox-clone plugin: [INFO] PACKER_CONFIG env var set; attempting to open config file: /home/user/.packerconfig
2022/02/22 19:33:08 packer-builder-proxmox-clone plugin: [WARN] Config file doesn't exist: /home/user/.packerconfig
2022/02/22 19:33:08 packer-builder-proxmox-clone plugin: [INFO] Setting cache directory: /home/user/.cache/packer
2022/02/22 19:33:08 packer-builder-proxmox-clone plugin: args: []string{"packer-builder-proxmox-clone"}
2022/02/22 19:33:08 packer-builder-proxmox-clone plugin: Plugin address: unix /tmp/packer-plugin4088226102
2022/02/22 19:33:08 packer-builder-proxmox-clone plugin: Waiting for connection...
2022/02/22 19:33:08 Received unix RPC address for /home/linuxbrew/.linuxbrew/Cellar/packer/1.7.10/libexec/bin/packer: addr is /tmp/packer-plugin4088226102
2022/02/22 19:33:08 packer-builder-proxmox-clone plugin: Serving a plugin connection...
2022/02/22 19:33:08 packer-builder-proxmox-clone plugin: Number of cores 0 is too small, using default: 1
2022/02/22 19:33:08 packer-builder-proxmox-clone plugin: Number of sockets 0 is too small, using default: 1
2022/02/22 19:33:08 packer-builder-proxmox-clone plugin: CPU type not set, using default 'kvm64'
2022/02/22 19:33:08 [TRACE] Starting internal plugin packer-provisioner-shell
2022/02/22 19:33:08 Starting plugin: /home/linuxbrew/.linuxbrew/Cellar/packer/1.7.10/libexec/bin/packer []string{"/home/linuxbrew/.linuxbrew/Cellar/packer/1.7.10/libexec/bin/packer", "plugin", "packer-provisioner-shell"}
2022/02/22 19:33:08 Waiting for RPC address for: /home/linuxbrew/.linuxbrew/Cellar/packer/1.7.10/libexec/bin/packer
2022/02/22 19:33:08 packer-provisioner-shell plugin: [INFO] Packer version: 1.7.10 [go1.17.6 linux amd64]
2022/02/22 19:33:08 packer-provisioner-shell plugin: [INFO] PACKER_CONFIG env var not set; checking the default config file path
2022/02/22 19:33:08 packer-provisioner-shell plugin: [INFO] PACKER_CONFIG env var set; attempting to open config file: /home/user/.packerconfig
2022/02/22 19:33:08 packer-provisioner-shell plugin: [WARN] Config file doesn't exist: /home/user/.packerconfig
2022/02/22 19:33:08 packer-provisioner-shell plugin: [INFO] Setting cache directory: /home/user/.cache/packer
2022/02/22 19:33:08 packer-provisioner-shell plugin: args: []string{"packer-provisioner-shell"}
2022/02/22 19:33:08 Received unix RPC address for /home/linuxbrew/.linuxbrew/Cellar/packer/1.7.10/libexec/bin/packer: addr is /tmp/packer-plugin3016092351
2022/02/22 19:33:08 packer-provisioner-shell plugin: Plugin address: unix /tmp/packer-plugin3016092351
2022/02/22 19:33:08 packer-provisioner-shell plugin: Waiting for connection...
2022/02/22 19:33:08 packer-provisioner-shell plugin: Serving a plugin connection...
2022/02/22 19:33:08 Build debug mode: false
2022/02/22 19:33:08 Force build: false
2022/02/22 19:33:08 On error: 
proxmox-clone.autogenerated_1: output will be in this color.
2022/02/22 19:33:08 Waiting on builds to complete...

2022/02/22 19:33:08 Starting build run: proxmox-clone.autogenerated_1
2022/02/22 19:33:08 Running builder: 
2022/02/22 19:33:08 [INFO] (telemetry) Starting builder proxmox-clone.autogenerated_1
2022/02/22 19:33:08 packer-builder-proxmox-clone plugin: using token auth
==> proxmox-clone.autogenerated_1: Creating ephemeral key pair for SSH communicator...
==> proxmox-clone.autogenerated_1: Created ephemeral SSH key pair for communicator
==> proxmox-clone.autogenerated_1: Creating VM
==> proxmox-clone.autogenerated_1: No VM ID given, getting next free from Proxmox
==> proxmox-clone.autogenerated_1: Starting VM
2022/02/22 19:33:21 packer-builder-proxmox-clone plugin: No boot command given, skipping
==> proxmox-clone.autogenerated_1: Using SSH communicator to connect: 192.168.0.144
2022/02/22 19:33:21 packer-builder-proxmox-clone plugin: [INFO] Waiting for SSH, up to timeout: 5m0s
==> proxmox-clone.autogenerated_1: Waiting for SSH to become available...
2022/02/22 19:33:36 packer-builder-proxmox-clone plugin: [DEBUG] TCP connection to SSH ip/port failed: dial tcp 192.168.0.144:22: i/o timeout
2022/02/22 19:33:41 packer-builder-proxmox-clone plugin: [INFO] Attempting SSH connection to 192.168.0.144:22...
2022/02/22 19:33:41 packer-builder-proxmox-clone plugin: [DEBUG] reconnecting to TCP connection for SSH
2022/02/22 19:33:41 packer-builder-proxmox-clone plugin: [DEBUG] handshaking with SSH
2022/02/22 19:33:42 packer-builder-proxmox-clone plugin: [DEBUG] handshake complete!
2022/02/22 19:33:42 packer-builder-proxmox-clone plugin: [DEBUG] Opening new ssh session
2022/02/22 19:33:44 packer-builder-proxmox-clone plugin: [INFO] agent forwarding enabled
==> proxmox-clone.autogenerated_1: Connected to SSH!
2022/02/22 19:33:44 packer-builder-proxmox-clone plugin: Running the provision hook
2022/02/22 19:33:44 [INFO] (telemetry) Starting provisioner shell
==> proxmox-clone.autogenerated_1: Provisioning with shell script: /tmp/packer-shell3898576573
2022/02/22 19:33:44 packer-provisioner-shell plugin: Opening /tmp/packer-shell3898576573 for reading
2022/02/22 19:33:44 packer-provisioner-shell plugin: [INFO] 41 bytes written for 'uploadData'
2022/02/22 19:33:44 [INFO] 41 bytes written for 'uploadData'
2022/02/22 19:33:44 packer-builder-proxmox-clone plugin: [DEBUG] Opening new ssh session
2022/02/22 19:33:44 packer-builder-proxmox-clone plugin: [DEBUG] Starting remote scp process:  scp -vt /tmp
2022/02/22 19:33:44 packer-builder-proxmox-clone plugin: [DEBUG] Started SCP session, beginning transfers...
2022/02/22 19:33:44 packer-builder-proxmox-clone plugin: [DEBUG] Copying input data into temporary file so we can read the length
2022/02/22 19:33:44 packer-builder-proxmox-clone plugin: [DEBUG] scp: Uploading script_9232.sh: perms=C0644 size=41
2022/02/22 19:33:44 packer-builder-proxmox-clone plugin: [DEBUG] SCP session complete, closing stdin pipe.
2022/02/22 19:33:44 packer-builder-proxmox-clone plugin: [DEBUG] Waiting for SSH session to complete.
2022/02/22 19:33:44 packer-builder-proxmox-clone plugin: [DEBUG] scp stderr (length 30): Sink: C0644 41 script_9232.sh
2022/02/22 19:33:44 packer-builder-proxmox-clone plugin: [DEBUG] Opening new ssh session
2022/02/22 19:33:44 packer-builder-proxmox-clone plugin: [DEBUG] starting remote command: chmod 0755 /tmp/script_9232.sh
2022/02/22 19:33:44 packer-builder-proxmox-clone plugin: [INFO] RPC endpoint: Communicator ended with: 0
2022/02/22 19:33:44 [INFO] RPC client: Communicator ended with: 0
2022/02/22 19:33:44 [INFO] RPC endpoint: Communicator ended with: 0
2022/02/22 19:33:44 packer-provisioner-shell plugin: [INFO] RPC client: Communicator ended with: 0
2022/02/22 19:33:44 packer-builder-proxmox-clone plugin: [DEBUG] Opening new ssh session
2022/02/22 19:33:44 packer-builder-proxmox-clone plugin: [DEBUG] starting remote command: chmod +x /tmp/script_9232.sh; PACKER_BUILDER_TYPE='proxmox-clone' PACKER_BUILD_NAME='autogenerated_1' PACKER_HTTP_PORT='0'  /tmp/script_9232.sh
    proxmox-clone.autogenerated_1: test
2022/02/22 19:33:54 packer-builder-proxmox-clone plugin: [INFO] RPC endpoint: Communicator ended with: 0
2022/02/22 19:33:54 [INFO] 0 bytes written for 'stderr'
2022/02/22 19:33:54 [INFO] 9 bytes written for 'stdout'
2022/02/22 19:33:54 [INFO] RPC client: Communicator ended with: 0
2022/02/22 19:33:54 [INFO] RPC endpoint: Communicator ended with: 0
2022/02/22 19:33:54 packer-provisioner-shell plugin: [INFO] 9 bytes written for 'stdout'
    proxmox-clone.autogenerated_1: bye
2022/02/22 19:33:54 packer-provisioner-shell plugin: [INFO] 0 bytes written for 'stderr'
2022/02/22 19:33:54 packer-provisioner-shell plugin: [INFO] RPC client: Communicator ended with: 0
2022/02/22 19:33:54 packer-builder-proxmox-clone plugin: [DEBUG] Opening new ssh session
2022/02/22 19:33:54 packer-builder-proxmox-clone plugin: [DEBUG] starting remote command: rm -f /tmp/script_9232.sh
2022/02/22 19:33:54 packer-builder-proxmox-clone plugin: [INFO] RPC endpoint: Communicator ended with: 0
2022/02/22 19:33:54 [INFO] RPC client: Communicator ended with: 0
2022/02/22 19:33:54 [INFO] RPC endpoint: Communicator ended with: 0
2022/02/22 19:33:54 packer-provisioner-shell plugin: [INFO] RPC client: Communicator ended with: 0
2022/02/22 19:33:54 packer-builder-proxmox-clone plugin: [DEBUG] Opening new ssh session
2022/02/22 19:33:54 packer-builder-proxmox-clone plugin: [DEBUG] starting remote command: rm -f
2022/02/22 19:33:54 packer-builder-proxmox-clone plugin: [INFO] RPC endpoint: Communicator ended with: 0
2022/02/22 19:33:54 [INFO] RPC client: Communicator ended with: 0
2022/02/22 19:33:54 [INFO] RPC endpoint: Communicator ended with: 0
2022/02/22 19:33:54 packer-provisioner-shell plugin: [INFO] RPC client: Communicator ended with: 0
2022/02/22 19:33:54 [INFO] (telemetry) ending shell
==> proxmox-clone.autogenerated_1: Trying to remove ephemeral keys from authorized_keys files
2022/02/22 19:33:54 packer-builder-proxmox-clone plugin: [DEBUG] Opening new ssh session
2022/02/22 19:33:54 packer-builder-proxmox-clone plugin: [DEBUG] starting remote command: sed -i.bak '/ packer_62152c64-c1bf-6edb-f245-1312cabd526e$/d' ~/.ssh/authorized_keys; rm ~/.ssh/authorized_keys.bak
2022/02/22 19:33:54 packer-builder-proxmox-clone plugin: [DEBUG] Opening new ssh session
2022/02/22 19:33:54 packer-builder-proxmox-clone plugin: [DEBUG] starting remote command: sudo sed -i.bak '/ packer_62152c64-c1bf-6edb-f245-1312cabd526e$/d' /root/.ssh/authorized_keys; sudo rm /root/.ssh/authorized_keys.bak
==> proxmox-clone.autogenerated_1: Stopping VM
==> proxmox-clone.autogenerated_1: Converting VM to template
2022/02/22 19:33:59 packer-builder-proxmox-clone plugin: template_id: 133
2022/02/22 19:33:59 [INFO] (telemetry) ending proxmox-clone.autogenerated_1
==> Wait completed after 50 seconds 929 milliseconds
==> Builds finished. The artifacts of successful builds are:
Build 'proxmox-clone.autogenerated_1' finished after 50 seconds 929 milliseconds.
2022/02/22 19:33:59 machine readable: proxmox-clone.autogenerated_1,artifact-count []string{"1"}

==> Wait completed after 50 seconds 929 milliseconds

==> Builds finished. The artifacts of successful builds are:
2022/02/22 19:33:59 machine readable: proxmox-clone.autogenerated_1,artifact []string{"0", "builder-id", "proxmox.clone"}
2022/02/22 19:33:59 machine readable: proxmox-clone.autogenerated_1,artifact []string{"0", "id", "133"}
2022/02/22 19:33:59 machine readable: proxmox-clone.autogenerated_1,artifact []string{"0", "string", "A template was created: 133"}
2022/02/22 19:33:59 machine readable: proxmox-clone.autogenerated_1,artifact []string{"0", "files-count", "0"}
2022/02/22 19:33:59 machine readable: proxmox-clone.autogenerated_1,artifact []string{"0", "end"}
--> proxmox-clone.autogenerated_1: A template was created: 133
2022/02/22 19:33:59 [INFO] (telemetry) Finalizing.
2022/02/22 19:34:00 waiting for all plugin processes to complete...
2022/02/22 19:34:00 /home/linuxbrew/.linuxbrew/Cellar/packer/1.7.10/libexec/bin/packer: plugin process exited
2022/02/22 19:34:00 /home/linuxbrew/.linuxbrew/Cellar/packer/1.7.10/libexec/bin/packer: plugin process exited

storage format qcow2 unsupporter with packer 1.8.1-1

Overview of the Issue

Hello,

It seems that packer errors out when trying to deploy a template and it complains about qcow2 being unsupported. So I thought I would start here rather than on the hashicorp forum, as I'm not really sure where the problem lies.

Reproduction Steps

Running packer build on a proxmox server generates this error. This isn't happening with packer 1.8.0.

Plugin and Packer version

v.18.1

Simplified Packer Buildfile

{
  "builders": [
    {
      "type": "proxmox",
      "proxmox_url": "https://{{ user `proxmox_host` }}:8006/api2/json",
      "username": "{{ user `proxmox_username` }}",
      "token": "{{ user `proxmox_token` }}",
      "node": "{{ user `proxmox_node_name` }}",
      "ssh_password": "{{ user `ssh_password` }}",
      "ssh_timeout": "30m",
      "ssh_username": "{{ user `ssh_username` }}",
      "template_name": "{{ user `template_name` }}",
      "template_description": "{{ user `template_description` }}",
      "sockets": 1,
      "cores": 4,
      "memory": 6144,
      "disks": [
        {
          "type": "scsi",
          "disk_size": "10G",
          "format": "qcow2",
          "storage_pool": "local-lvm",
          "storage_pool_type": "lvm-thin",
          "cache_mode": "none",
          "io_thread": "false"
        }
      ],
      "network_adapters": [
        {
          "bridge": "vmbr0",
          "model": "virtio"
        }
      ],
      "os": "l26",
      "unmount_iso": true,
      "cloud_init": true,
      "cloud_init_storage_pool": "cloudinit",
      "http_directory": "http",
      "http_interface": "ens160",
      "http_port_max": 8039,
      "http_port_min": 8039,
      "insecure_skip_tls_verify": false,
      "iso_checksum": "f8e3086f3cea0fb3fefb29937ab5ed9d19e767079633960ccb50e76153effc98",
      "iso_file": "nfs:iso/ubuntu-22.04-live-server-amd64.iso",
      "boot_wait": "4s",
      "boot_command": [
        "<e><bs><down><down><down>",
	"<right><right><right><right><right><right><right><right><right><right><right><right><right><right><right><right><right><right><right><right><right><right><right>",
        "<spacebar>",
        "ip={{ user `vm_ip` }}::{{ user `vm_gateway` }}:{{ user `vm_netmask` }}::::{{ user `vm_dns` }} ",
        "autoinstall 'ds=nocloud-net;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/' ",
        "<F10>"
      ]
    },
[...]
  "variables": {
    "vm_ip": "10.88.88.157",
    "vm_netmask": "255.255.255.0",
    "vm_gateway": "10.88.88.126",
    "vm_dns": "10.88.88.126",
    "search_domain:": "mydomain.com",
    "dns_server:": "10.88.88.126",
    "template_name": "packer-template",
    "template_description": "Ubuntu 22.04, generated by packer on {{ isotime }}",
    "playbook": "setup/work.yml",
    "ssh_password": "",
    "ssh_username": "",
    "vmware_build": "no",
    "vsphere_build_host": "",
    "vsphere_datastore": "",
    "vsphere_folder": "",
    "vsphere_cluster": "",
    "vsphere_network": "",
    "vsphere_password": "",
    "vsphere_username": ""
  }

Operating system and Environment details

Running packer on Ubuntu 20.04.4

Log Fragments and crash.log files

2022/06/05 16:16:55 [INFO] Packer version: 1.8.1 [go1.17.8 linux amd64]
2022/06/05 16:16:55 [TRACE] discovering plugins in /usr/bin
2022/06/05 16:16:55 [TRACE] discovering plugins in /root/.config/packer/plugins
2022/06/05 16:16:55 [TRACE] discovering plugins in .
2022/06/05 16:16:55 [INFO] PACKER_CONFIG env var not set; checking the default config file path
2022/06/05 16:16:55 [INFO] PACKER_CONFIG env var set; attempting to open config file: /root/.packerconfig
2022/06/05 16:16:55 [WARN] Config file doesn't exist: /root/.packerconfig
2022/06/05 16:16:55 [INFO] Setting cache directory: /root/.cache/packer
2022/06/05 16:16:55 [TRACE] Starting internal plugin packer-builder-proxmox
2022/06/05 16:16:55 Starting plugin: /usr/bin/packer []string{"/usr/bin/packer", "plugin", "packer-builder-proxmox"}
2022/06/05 16:16:55 Waiting for RPC address for: /usr/bin/packer
2022/06/05 16:16:55 packer-builder-proxmox plugin: [INFO] Packer version: 1.8.1 [go1.17.8 linux amd64]
2022/06/05 16:16:55 Received unix RPC address for /usr/bin/packer: addr is /tmp/packer-plugin2630202321
2022/06/05 16:16:55 packer-builder-proxmox plugin: [INFO] PACKER_CONFIG env var not set; checking the default config file path
2022/06/05 16:16:55 packer-builder-proxmox plugin: [INFO] PACKER_CONFIG env var set; attempting to open config file: /root/.packerconfig
2022/06/05 16:16:55 packer-builder-proxmox plugin: [WARN] Config file doesn't exist: /root/.packerconfig
2022/06/05 16:16:55 packer-builder-proxmox plugin: [INFO] Setting cache directory: /root/.cache/packer
2022/06/05 16:16:55 packer-builder-proxmox plugin: args: []string{"packer-builder-proxmox"}
2022/06/05 16:16:55 [TRACE] Starting internal plugin packer-provisioner-ansible
2022/06/05 16:16:55 Starting plugin: /usr/bin/packer []string{"/usr/bin/packer", "plugin", "packer-provisioner-ansible"}
2022/06/05 16:16:55 Waiting for RPC address for: /usr/bin/packer
2022/06/05 16:16:55 packer-builder-proxmox plugin: Plugin address: unix /tmp/packer-plugin2630202321
2022/06/05 16:16:55 packer-builder-proxmox plugin: Waiting for connection...
2022/06/05 16:16:55 packer-builder-proxmox plugin: Serving a plugin connection...
2022/06/05 16:16:55 packer-provisioner-ansible plugin: [INFO] Packer version: 1.8.1 [go1.17.8 linux amd64]
2022/06/05 16:16:55 packer-provisioner-ansible plugin: [INFO] PACKER_CONFIG env var not set; checking the default config file path
2022/06/05 16:16:55 packer-provisioner-ansible plugin: [INFO] PACKER_CONFIG env var set; attempting to open config file: /root/.packerconfig
2022/06/05 16:16:55 packer-provisioner-ansible plugin: [WARN] Config file doesn't exist: /root/.packerconfig
2022/06/05 16:16:55 packer-provisioner-ansible plugin: [INFO] Setting cache directory: /root/.cache/packer
2022/06/05 16:16:55 packer-provisioner-ansible plugin: args: []string{"packer-provisioner-ansible"}
2022/06/05 16:16:55 packer-provisioner-ansible plugin: Plugin address: unix /tmp/packer-plugin3530321557
2022/06/05 16:16:55 Received unix RPC address for /usr/bin/packer: addr is /tmp/packer-plugin3530321557
2022/06/05 16:16:55 packer-provisioner-ansible plugin: Waiting for connection...
2022/06/05 16:16:55 packer-provisioner-ansible plugin: Serving a plugin connection...
2022/06/05 16:16:55 Preparing build: proxmox
2022/06/05 16:16:55 packer-builder-proxmox plugin: CPU type not set, using default 'kvm64'
2022/06/05 16:16:55 packer-builder-proxmox plugin: SCSI controller not set, using default 'lsi'
proxmox: output will be in this color.
2022/06/05 16:16:56 Build debug mode: false
2022/06/05 16:16:56 Force build: false
2022/06/05 16:16:56 On error: abort
2022/06/05 16:16:56 Waiting on builds to complete...
2022/06/05 16:16:56 Starting build run: proxmox
2022/06/05 16:16:56 Running builder: proxmox

2022/06/05 16:16:56 [INFO] (telemetry) Starting builder proxmox
2022/06/05 16:16:56 packer-provisioner-ansible plugin: ansible-playbook version: 2.12.6
==> proxmox: Creating VM
2022/06/05 16:16:56 packer-builder-proxmox plugin: using token auth
2022/06/05 16:16:56 packer-builder-proxmox plugin: No URLs were provided to Step Download. Continuing...
==> proxmox: No VM ID given, getting next free from Proxmox
==> proxmox: Error creating VM: error creating VM: unable to create VM 112 - unsupported format 'qcow2' at /usr/share/perl5/PVE/Storage/LvmThinPlugin.pm line 87., error status:  (params: map[agent:1 args: boot: cores:4 cpu:kvm64 description:Packer ephemeral build VM hotplug: ide2:nfs:iso/ubuntu-22.04-live-server-amd64.iso,media=cdrom kvm:true machine: memory:6144 name:packer-629cd6f7-1a53-e158-3fa1-9631569995bb net0:virtio=FA:1A:ED:20:9B:76,bridge=vmbr0,firewall=false numa:false onboot:false ostype:l26 scsi0:local-lvm:10,format=qcow2,iothread=false scsihw:lsi sockets:1 tablet:false tags: vmid:112])
==> proxmox: Error creating VM: error creating VM: unable to create VM 112 - unsupported format 'qcow2' at /usr/share/perl5/PVE/Storage/LvmThinPlugin.pm line 87., error status:  (params: map[agent:1 args: boot: cores:4 cpu:kvm64 description:Packer ephemeral build VM hotplug: ide2:nfs:iso/ubuntu-22.04-live-server-amd64.iso,media=cdrom kvm:true machine: memory:6144 name:packer-629cd6f7-1a53-e158-3fa1-9631569995bb net0:virtio=FA:1A:ED:20:9B:76,bridge=vmbr0,firewall=false numa:false onboot:false ostype:l26 scsi0:local-lvm:10,format=qcow2,iothread=false scsihw:lsi sockets:1 tablet:false tags: vmid:112])
==> proxmox: Step "stepStartVM" failed, aborting...
2022/06/05 16:16:58 [INFO] (telemetry) ending proxmox
==> Wait completed after 2 seconds 111 milliseconds
==> proxmox: aborted: skipping cleanup of step "stepUploadISO"
==> proxmox: aborted: skipping cleanup of step "StepDownload"
2022/06/05 16:16:58 machine readable: error-count []string{"1"}
==> Some builds didn't complete successfully and had errors:
2022/06/05 16:16:58 machine readable: proxmox,error []string{"Error creating VM: error creating VM: unable to create VM 112 - unsupported format 'qcow2' at /usr/share/perl5/PVE/Storage/LvmThinPlugin.pm line 87., error status:  (params: map[agent:1 args: boot: cores:4 cpu:kvm64 description:Packer ephemeral build VM hotplug: ide2:nfs:iso/ubuntu-22.04-live-server-amd64.iso,media=cdrom kvm:true machine: memory:6144 name:packer-629cd6f7-1a53-e158-3fa1-9631569995bb net0:virtio=FA:1A:ED:20:9B:76,bridge=vmbr0,firewall=false numa:false onboot:false ostype:l26 scsi0:local-lvm:10,format=qcow2,iothread=false scsihw:lsi sockets:1 tablet:false tags: vmid:112])"}
==> Builds finished but no artifacts were created.
2022/06/05 16:16:58 [INFO] (telemetry) Finalizing.
Build 'proxmox' errored after 2 seconds 111 milliseconds: Error creating VM: error creating VM: unable to create VM 112 - unsupported format 'qcow2' at /usr/share/perl5/PVE/Storage/LvmThinPlugin.pm line 87., error status:  (params: map[agent:1 args: boot: cores:4 cpu:kvm64 description:Packer ephemeral build VM hotplug: ide2:nfs:iso/ubuntu-22.04-live-server-amd64.iso,media=cdrom kvm:true machine: memory:6144 name:packer-629cd6f7-1a53-e158-3fa1-9631569995bb net0:virtio=FA:1A:ED:20:9B:76,bridge=vmbr0,firewall=false numa:false onboot:false ostype:l26 scsi0:local-lvm:10,format=qcow2,iothread=false scsihw:lsi sockets:1 tablet:false tags: vmid:112])

==> Wait completed after 2 seconds 111 milliseconds

==> Some builds didn't complete successfully and had errors:
--> proxmox: Error creating VM: error creating VM: unable to create VM 112 - unsupported format 'qcow2' at /usr/share/perl5/PVE/Storage/LvmThinPlugin.pm line 87., error status:  (params: map[agent:1 args: boot: cores:4 cpu:kvm64 description:Packer ephemeral build VM hotplug: ide2:nfs:iso/ubuntu-22.04-live-server-amd64.iso,media=cdrom kvm:true machine: memory:6144 name:packer-629cd6f7-1a53-e158-3fa1-9631569995bb net0:virtio=FA:1A:ED:20:9B:76,bridge=vmbr0,firewall=false numa:false onboot:false ostype:l26 scsi0:local-lvm:10,format=qcow2,iothread=false scsihw:lsi sockets:1 tablet:false tags: vmid:112])

==> Builds finished but no artifacts were created.
2022/06/05 16:16:59 waiting for all plugin processes to complete...
2022/06/05 16:16:59 /usr/bin/packer: plugin process exited
2022/06/05 16:16:59 /usr/bin/packer: plugin process exited

I've tested this on both proxmox 6.4-14 and 7.2-4.

Feature: Allow the use of raw/qcow2 Cloud Images (Debian/Ubuntu/CentOS/etc.)

Community Note

Please vote on this issue by adding a ๐Ÿ‘ reaction to the original issue to help the community and maintainers prioritize this request.
Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request.
If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Description

Various distros provide cloud init-ready disk images, like Ubuntu, Debian, CentOS, etc. These are no ISO files so won't work as CD image and should be added as hard disk instead.

If I'm right, the Packer Proxmox plugin doesn't allow direct disk attachments currently. ๐Ÿค”

Use Case(s)

As Proxmox's Cloud-Init compatibility matures, it's logical to skip ISO installations and start using Cloud Init for the (base) deployment.

Potential configuration

Maybe add an image_url and image_path to the disk blocks. image_url could download the cloud image and upload it to the node, like iso_url would do for the ISO image.

# ...
source "proxmox" "autogenerated_1" {
  # ...
  disks {
    image_url         = "https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-genericcloud-amd64.qcow2"
    # ...
    disk_size         = "50G"
    storage_pool      = "local-lvm"
    storage_pool_type = "lvm"
    type              = "scsi"
  }
}
# ...

Potential References

This gist describes the outline of the CLI steps to add a VM with direct cloud images as disks:
https://gist.github.com/chriswayg/b6421dcc69cb3b7e41f2998f1150e1df

I found out that I'm too far from a GO-developer myself yet to provide a first setup towards my goal, so hopefully this isn't too much of a hassle.

promox-iso check if iso already exists on datastore

This issue was originally opened by @Syntax3rror404 in hashicorp/packer#10756 and has been migrated to this repository. The original issue description is below.


Community Note

Please vote on this issue by adding a ๐Ÿ‘ reaction to the original issue to help the community and maintainers prioritize this request.
Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request.
If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Description

The iso is uploaded to the proxmox datastore with every Packer build. Since Packer already knows the checksum, a check would be possible. This feature was also recently implemented for the vsphere-iso provider. Please also implement this feature for the proxmox-iso provider.

Use Case(s)

-Saves time
-Building from the other network is possible (It takes forever to have to upload an iso from the Internet every time )
-Can protect the SSD from senseless writing
-Better quality of the Packer Provider code

Potential configuration

See vmware-iso provider
All variables are already implementent.

Potential References

See vmware-iso provider

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.