Skip to content

Importing LXC container does not import unprivileged flag value #1787

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

Closed
Renerick opened this issue Feb 23, 2025 · 2 comments · Fixed by #1867
Closed

Importing LXC container does not import unprivileged flag value #1787

Renerick opened this issue Feb 23, 2025 · 2 comments · Fixed by #1867
Labels

Comments

@Renerick
Copy link

Describe the bug
Importing LXC container does not import unprivileged flag value, so when trying to update the container, it is forced to be recreated

To Reproduce
Steps to reproduce the behavior:

  1. Create a container with unprivileged = true
  2. Remove the state
  3. Import the container back to (terraform import)
  4. Run terraform plan
  5. See error of terraform wanting to replace the container because of unprivileged field

Note: there are other fields that are not imported too, such as user password, keys and container template file name. As far as I understand, there is no way to get those fields from proxmox API, so no questions here.

Please also provide a minimal Terraform configuration that reproduces the issue.

resource "proxmox_virtual_environment_container" "ubuntu_container" {
  vm_id     = 9876

  node_name = "pve-1"
  unprivileged = true

  features {
    nesting = true
  }

  initialization {
    hostname = "repro"

    ip_config {
      ipv4 {
        address = "10.0.0.2/16"
        gateway = "10.0.0.1"
      }
    }

    user_account {
      password = "pwdpwd"
    }
  }

  network_interface {
    name = "eth0"
  }

  disk {
    size = 4
    // put your disk in here
  }

  cpu {
    cores = 1
  }

  operating_system {
    template_file_id = "local:vztmpl/ubuntu-24.10-standard_24.10-1_amd64.tar.zst"
    type             = "ubuntu"
  }
}

and the output of terraform|tofu apply.

...
unprivileged   = true # forces replacement
...

Expected behavior
Unprivileged value is imported correctly

Screenshots
If applicable, add screenshots to help explain your problem.

N/A

Additional context
Add any other context about the problem here.

  • Single or clustered Proxmox: single node
  • Proxmox version: Virtual Environment 8.3.4
  • Provider version (ideally it should be the latest version): 0.72.0
  • Terraform/OpenTofu version:
    Terraform v1.10.5
    on windows_amd64
    
  • OS (where you run Terraform/OpenTofu from): Windows 10 x64
  • Debug logs (TF_LOG=DEBUG terraform apply):
@bpg
Copy link
Owner

bpg commented Feb 26, 2025

Briefly checked the code, I think unprivileged is missing from the containerRead func.

@CaptaiNiveau
Copy link
Contributor

CaptaiNiveau commented Mar 29, 2025

I just bumped into this issue as well. That pointer is nice, I found the method and added the missing segment (same as Protection).

Will set up the Proxmox VM tomorrow to run the tests and see if it works as expected ^^

If it does, I'll send the PR tomorrow.

@bpg bpg closed this as completed in #1867 Mar 31, 2025
@github-project-automation github-project-automation bot moved this from 📥 Inbox to ✅ Done in terraform-provider-proxmox Mar 31, 2025
@bpg bpg marked this as a duplicate of #1406 Mar 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants