Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proxmox-clone does not honor os argument #66

Closed
mabeett opened this issue Feb 22, 2022 · 4 comments · Fixed by #130
Closed

proxmox-clone does not honor os argument #66

mabeett opened this issue Feb 22, 2022 · 4 comments · Fixed by #130

Comments

@mabeett
Copy link
Contributor

mabeett commented Feb 22, 2022

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
@mabeett mabeett added the bug label Feb 22, 2022
@nywilken
Copy link
Contributor

nywilken commented Nov 1, 2022

Hi releases of the proxmox builders prior to v1.1.0, which was released today, were incorrectly registered as proxmox-promox-iso and proxmox-proxmox-clone. I suspect that this bug has to do with the the embedded version of the Proxmox being used over any externally installed version of the plugin.

You are encouraged to upgrade any locally installed version of this plugin to v1.1.0 and try again if you are still running into issues.

Refer to #119 for more details.

You can use the Packer init command to install the plugin by adding the following block to your template.

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

@mabeett
Copy link
Contributor Author

mabeett commented Nov 20, 2022

Hello,
I applied the changed you mentioned, the
The problem persists using this versions:

  • Packer v1.8.4
  • packer-plugin-proxmox v1.1.0

@mabeett
Copy link
Contributor Author

mabeett commented Nov 27, 2022

Hi,
I have been studying this issue using -debug option and PACKER_LOG environment variable.
The plugin does not send the variable ostype in the POST /api2/json/nodes/${node}/qemu/${vm_id}/config HTTP/1.1 POST request.
Based on logs messages I left in the code I believe the problem is in the Telmate/proxmox-api-go module which is not honoring client.QemuOs in config.UpdateConfig() invocation for Create() in file builder/proxmox/clone/builder.go.
I am going to try to leave a PR in the module project ( I'm just spending part of my spare time and I am far away of being a go programmer)

@mabeett
Copy link
Contributor Author

mabeett commented Dec 17, 2022

Hi,
Recently I made A PR in Telmate/proxmox-api-go repository and the changes are now on master.
Updating the reference to the module will solve this issue according as I tested manually.
kind regards,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants