[SOLVED] Error 401 when using Packer with username/api key

ws010

New Member
Dec 13, 2023
4
0
1
Hi,

I trying to use Packer with the Packer Proxmox ISO Builder but I do get a 401 error on ProxMox 8.1.3.

I have created this user/apikey and role assigned with this:
- pveum user add packer@pam - pveum aclmod / -user packer@pam -role Administrator. <----- Just for testing purposes - pveum user token add packer@pam packer-token --privsep=0

The Packer code
variables { proxmox_url = "https://proxmox.xxxxx.xx:8006/api2/json" proxmox_username = "packer@pam" proxmox_apitoken = "packer@pam!packer-token=daa7f68e-8196-4131-881f-0d0675f02529" <--- Is a dummy value } packer { required_plugins { proxmox = { version = " >= 1.1.6" source = "github.com/hashicorp/proxmox" } } } source "proxmox-iso" "proxmox-test" { proxmox_url = var.proxmox_url username = var.proxmox_username token = var.proxmox_apitoken }

This is the error output
proxmox-iso.proxmox-test: output will be in this color. ==> proxmox-iso.proxmox-test: Creating VM ==> proxmox-iso.proxmox-test: No VM ID given, getting next free from Proxmox ==> proxmox-iso.proxmox-test: 401 no such user ('packer@pam=packer@pam') Build 'proxmox-iso.proxmox-test' errored after 3 seconds 119 milliseconds: 401 no such user ('packer@pam=packer@pam')

Does anybody know why this is failing? Thanks
 
==> proxmox-iso.proxmox-test: 401 no such user ('packer@pam=packer@pam')
The user does not appear to exist. Have you checked that it was created? Can you log in to the GUI or API with this?

Could it be that Packer expects @pve and not @pam and that is hardcoded somewhere?
 
Thanks. I have tried to create the user with @pam and @pve, both not working.

With the apikey I cannot logon into the GUI (obvious), with login as root I can see the created packer user and apikey. Is there an example to test the apiuser/apikey from the command line?
 
You can do something like this here, for example. To use it, you would just have to adapt it a bit so that it can be used with API tokens.
Bash:
curl -k -d 'username=USER@pve' --data-urlencode 'password=PASSWORD' https://NODE_URL:8006/api2/json/access/ticket
Source: https://forum.proxmox.com/threads/proxmox-api-example-for-dummies.112366/

You may also need to use packer@pam!packer-token instead of packer@pam as a user since you want to authenticate with an API token.
 
Thanks again, found the solution, I am also using Terraform and assumed it was the same, but not :)

The username is the name including the tokenid and the token itself is only the token. RTFM :)
proxmox_username = "packer@pam!packer"
proxmox_apitoken = "4a59a60d-f1a5-4857-9184-c1480b58b789" <---Dummy again

Thanks for the fast response!
 
Hi @ws010 ,

Would you mind to share the steps that you performed on proxmox 8.x UI (ot the guide that you followed)?
I'm using the same packer files that I used with my old 7.x instance and I get this error:

Code:
2024/02/21 09:02:41 packer-plugin-proxmox_v1.1.7_x5.0_linux_amd64 plugin: 2024/02/21 09:02:4
1 No URLs were provided to Step Download. Continuing...
==> ubuntu-VM.proxmox-iso.ubuntu-VM: 400 Parameter verification failed.
==> ubuntu-VM.proxmox-iso.ubuntu-VM: delete volume failed: 501 Method 'DELETE /nodes/<sensit
ive>/storage/local/content/' not implemented                                               
2024/02/21 09:02:42 [INFO] (telemetry) ending proxmox-iso.ubuntu-VM
==> Wait completed after 200 milliseconds 25 microseconds
2024/02/21 09:02:42 machine readable: error-count []string{"1"}
==> Some builds didn't complete successfully and had errors:
2024/02/21 09:02:42 machine readable: ubuntu-VM.proxmox-iso.ubuntu-VM,error []string{"501 Me
thod 'DELETE /nodes/<sensitive>/storage/local/content/' not implemented"}
Build 'ubuntu-VM.proxmox-iso.ubuntu-VM' errored after 199 milliseconds 932 microseconds: 501
Method 'DELETE /nodes/<sensitive>/storage/local/content/' not implemented

Thanks
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!