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

Add support for proxmox_virtual_environment_file data source #1396

Open
VoidAndAny opened this issue Jun 16, 2024 · 3 comments
Open

Add support for proxmox_virtual_environment_file data source #1396

VoidAndAny opened this issue Jun 16, 2024 · 3 comments
Labels
✨ enhancement New feature or request

Comments

@VoidAndAny
Copy link

Not a bug, just need help to use the provider, maybe it's more terraform usage than provider help, feel free to close this issue if it's not appropriate.

In my usage, I separate each VM in directory but I want to use the same iso/vztmpl.

For now, I have a common directory with terraform configuration to download iso/vztmpl with proxmox_virtual_environment_download_file resource:

resource "proxmox_virtual_environment_download_file" "ubuntu_2204_cloud_image" {
  content_type = "iso"
  datastore_id = var.image_datastorestore_id
  node_name    = var.node_name
  overwrite    = false
  url          = "https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img"
}

Then in each VM directories I import them like this:

import {
  to = proxmox_virtual_environment_file.ubuntu_2204_vm_image
  id = "${var.node_name}/${var.image_datastorestore_id}:iso/jammy-server-cloudimg-amd64.img"
}
resource "proxmox_virtual_environment_file" "ubuntu_2204_vm_image" {
  content_type = "iso"
  datastore_id = var.image_datastorestore_id
  node_name    = var.node_name
  overwrite    = false
  lifecycle {
    prevent_destroy = true
  }
}

I had to configure lifecycle with prevent_destroy to preserve my image if I destroy VM (so I need to destroy with -targetoption)

Is there a better way (I tought use template but I prefer not) ?
In my terraform comprehension this had to be done with data source, but there is no data source for file ?

Thanks for your help

@VoidAndAny VoidAndAny added the 🐛 bug Something isn't working label Jun 16, 2024
@bpg
Copy link
Owner

bpg commented Jun 17, 2024

Hi @VoidAndAny 👋🏼

Yeah, the file datasource would make it easier. But you probably don't need to define resource "proxmox_virtual_environment_file" "ubuntu_2204_vm_image" within each VM folder either. You can use "${var.image_datastorestore_id}:iso/jammy-server-cloudimg-amd64.img" directly as a disk.file_id value in the VM.

@bpg bpg changed the title [Help] data source for file Add support for proxmox_virtual_environment_file data source Jun 17, 2024
@bpg bpg added ✨ enhancement New feature or request and removed 🐛 bug Something isn't working labels Jun 17, 2024
@VoidAndAny
Copy link
Author

Whaouh, so simple
You can close this issue if you want, thanks a lot

@bpg
Copy link
Owner

bpg commented Jun 18, 2024

I'll leave it, would be a useful feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants