terraform-provider-proxmox: Too many permissions needed to create a VM
I found that in version 2.9.14 should be much more permissions to create a VM compared to version 2.9.11 (not tested 2.9.13) Also, the error doesn’t say about which permissions you need.
Error in version 2.9.14 if you are using Token:
╷
│ Error: user username@pve has valid credentials but cannot retrieve user list, check privilege separation of api token
│
│ with provider["registry.terraform.io/telmate/proxmox"],
│ on main.tf line 25, in provider "proxmox":
│ 25: provider "proxmox" {
│
Error in version 2.9.14 if you are using Password:
╷
│ Error: Request cancelled
│
│ with provider["registry.terraform.io/telmate/proxmox"],
│ on main.tf line 25, in provider "proxmox":
│ 25: provider "proxmox" {
│
│ The plugin.(*GRPCProvider).ConfigureProvider request was cancelled.
╵
Compared to version 2.9.11 It needs additional permissions:
- Sys.Audit
- Sys.Modify
- Sys.Console
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 7
- Comments: 29 (11 by maintainers)
I had the same issue and I’ve fixed id in the gui. From the tree Datacenter > Permissions > API Tokens > {your token} On the edit page I’ve checked out “Privilege Separation”
Found it in this article https://medium.com/geekculture/connect-proxmox-and-terraform-using-provider-and-api-854a91f4b65d
This issue is stale because it has been open for 60 days with no activity. Please update the provider to the latest version and, in the issue persist, provide full configuration and debug logs
After a LOT of digging, I believe I’ve tracked down why Sys.Audit is necessary as of 2.9.13.
This can also be verified by logging in as the user associated with an API key and going to a URL like https://proxmox.example.com/api2/json/access/permissions?userid=apiusername@pam&path=/ to see the 401 Forbidden response. Drop the userid=xyz part, and you get a 200 OK response with your permissions as the content.
This appears to have been added by @mleone87 in commit 9b75cbb. All of this, ironically, is to enable the error messages to tell the user what permissions are needed, and to attempt to not start making changes if they are going to fail later.
The Sys.Audit permissions is only required to get the permission of other users. To get the permissions of yourself, the
userId=parameter can be omitted and the API will return the list of your permissions. In this case, we do want to get the permissions of ourselves, however client.go::GetUserPermissions() is written to get the permissions of a generic userId with no concept of getting the permissions of the logged in user.I propose the following to remove the need for Sys.Audit:
Obviously testing will be required to ensure there are not any other API calls that require Sys.Audit.
If anyone is willing to make this change, I can repeat this deep dive into the code to try to track down why Sys.Modify and Sys.Console are now required. I just want to make sure that spending more hours tracing through code, diffing commits, checking API docs, and the like is actually going to result in improvements at some point.
I had the same error and solved it by making sure I applied the correct permissions to the Token, not the User.
Just a heads up,
SDN.Useshould also be added to the documentation. This is needed even if you are not using SDN!I’m not sure when it was added to the required permissions, but I can confirm that it is needed by 3.0.1-rc6.
There was a reasonably nice error message indicating what permission it was that was missing, so that’s nice. However it’s unfortunate that the software will not run without this permission when it should not be needed unless you are using SDN features.
OK, I have more information on precisely what is required, but I don’t have any workarounds.
Before I get into the details, I have a few suggested paths forward:
If we can get some agreement on these two things, we can open a ticket to add the feature to not perform permission checks, and at least one ticket in the proxmox-api-go repo, as I believe most of the code that will need changed is going to be over there.
With the first ticket, it’s possible that we’ll find out that skipping the checks is not sufficient, and we’ll need to skip certain steps that we do now. If that turns out to be the case, then we’ll have to dig into the long term solution to get this resolved.
At this point, I’d like to try to get a consensus on whether these two paths forward seem like they’re an approach the people following this ticket want. Because the first step at resolving this issue is agreeing on the requirements and next steps.
2.9.11
I’ve done extensive testing and found that Sys.Audit, Sys.Console, and Sys.Modify are not actually required at all in v2.9.11. Here are the minimum required permissions as of version 2.9.11:
It’s possible there may be some terraform files that can be deployed with fewer permissions, but for the typical use case of cloning a base VM and configuring it, these are the minimum.
Here’s the terraform definitions for this test:
3.0.1-rc1
Then I changed the terraform file to use the 3.0.1-rc1 version of the provider, commented out the
disksection and uncommented thedisksblock.Round 1
Attempting to deploy resulted in the following errors:
If I add the permission for Sys.Audit, the error message becomes much more helpful.
Of these, the following are new and were not previously required:
To understand what these are, we can go to the Proxmox admin guide, which offers the explanations I’ve pasted below.
I’m not sure why VM.Monitor and Pool.Allocate are required, but the rest of these seem pretty reasonable. I could understand making VM.Config.CDROM and VM.Config.Cloudinit optional, as not everyone is going to want to use CloudInit. I did verify that the list of permissions in the error message did not change if I remove the cloudinit section of my terraform definition.
This left me more wondering how on Earth it was setting up Cloudinit (which uses an emulated CDROM) without those permissions. I can confirm that it was doing it though!
Round 2
After adding the permissions above, I then got the same error message, but with different permissions that were missing. The additional ones this time (along with what Proxmox’s documentation says they do) were:
However there were additional requirements that were harder to notice. The error also kept listing all the VM.* permissions unless I changed the scope to be “/” instead of “/vms”. The same was required for Datastore.AllocateSpace. Even using “/storage” was not sufficient, it had to be “/”.
Round 3
After adding all of the above permissions, the deployment started, but then failed with a 403 error. So after all those up-front checks, there were still some things that were needed that were not in that list! Here’s the error message:
I’m not sure what the problem was there, but after removing the permissions to specific paths, and keeping only the ones that covered “/”, it deployed without any issue. My best guess is that it has something to do with “propagation” which is whether the user gets permissions on entities that don’t exist yet (like /vms/101) just because they have the necessary permission on (/vms or /).
Unfortunately, the same problem, for two years I have not been able to provide the ability to use Proxmox to my users through terraform because of privileges. I hope the problem will be solved ASAP
Added those permissions when using an API token and am still seeing the same error
I am also using latest v3.0.1-rc6 and would be great to improve the
permissions_checkbased on what needs to be done and minimum permissions so we avoid any security issues resulting from adding more than neeed.My workaround to get working using user’s token with privilege separation and pool’s fine-grained permissions.
System details: Proxmox VE 8.2.2 Terraform v1.8.4 terraform-provider-proxmox v3.0.1-rc2
On PVE side (execution in pve terminal):
terraform-provider-proxmoxmodification:https://github.com/Telmate/terraform-provider-proxmox/blob/master/proxmox/provider.go#L196
Modify
minimumPermissionsas per below example (keep onlySys.Auditpermission):Proceed with manual build and install, as per documentation: https://github.com/Telmate/terraform-provider-proxmox/blob/master/docs/guides/installation.md#manual-build--install
I used
make local-dev-installand inmain.tfsource should be like this:In
main.tfdefine pool, which configured above:Run
terraform planandterraform apply. Now permission checking should ne passed and it is possible to create/destroy VMs in PVE, change VM parameters, add disks etc.So, for example, would be very nice and useful if will be such options in provider:
/minimumPermissionslistIt looks like there is at least one person who is unable to update to the latest version.
I fear you may be right that these permissions are likely now required and not doing the check is not going to resolve the issue, but there is a chance. I expect changing the code back to where it doesn’t require the additional permissions is going to take quite a long time and I don’t want to leave people hanging if there’s a way we can get them the same functionality that old versions had (which did not do proactive permission checks).
@hestiahacker Checking permissions dynamically was merged upstream https://github.com/Telmate/proxmox-api-go/issues/308
But after attempting to use this in multiple places, I’ve realized some shortfalls of it.