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

feat: cloud init disk resource #748

Merged
merged 8 commits into from
May 24, 2023

Conversation

lsjostro
Copy link
Contributor

@lsjostro lsjostro commented Apr 18, 2023

This new resource creates/manage cloud-init configdrive as ISO-files. It generates a cloud-init iso and uploads it to proxmox. This enables a wider/more advanced support for cloud-init then Proxmox currently supports.

To use the generated cloud-init iso, VMs just need to define a disk block with type=ide, media=cdrom and volume=proxmox_cloud_init_disk.<my_ci_resource>.id parameters.

Need to add docs before it's ready to be merged. But a first review would be helpful.

example:

resource "proxmox_cloud_init_disk" "ci" {
  name      = var.name
  pve_node  = var.pve_node
  storage   = "cephfs"

  meta_data = <<EOF
instance-id: ${var.name}
local-hostname: ${var.name}
EOF

  user_data = <<EOF
#cloud-config
users:
  - name: foo
    sudo: ALL=(ALL) NOPASSWD:ALL
EOF
  
  network_config = <<EOF
...your network config...
EOF
}

resource "proxmox_vm_qemu" "foo" {
....
  disk {
    type    = "ide"
    media   = "cdrom"
    storage = "cephfs"
    volume  = proxmox_cloud_init_disk.ci.id
    size    = proxmox_cloud_init_disk.ci.size
  }
...
}

@lsjostro lsjostro force-pushed the resource-vm-cloud-init branch 2 times, most recently from 8e875af to f5c689d Compare April 19, 2023 21:58
@lsjostro
Copy link
Contributor Author

added docs now, so I think it's ready for review!

Copy link
Collaborator

@mleone87 mleone87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great contribution, I left some comments otherwise LGTM

proxmox/provider.go Outdated Show resolved Hide resolved
proxmox/resource_cloud_init.go Outdated Show resolved Hide resolved
proxmox/resource_cloud_init.go Outdated Show resolved Hide resolved
proxmox/resource_cloud_init.go Outdated Show resolved Hide resolved
@lsjostro lsjostro changed the title new cloud init resource new cloud init disk resource Apr 24, 2023
@lsjostro lsjostro force-pushed the resource-vm-cloud-init branch 2 times, most recently from b3aa2a1 to dfff6aa Compare April 25, 2023 17:55
@lsjostro lsjostro force-pushed the resource-vm-cloud-init branch 2 times, most recently from d4cf61c to 9c3d90f Compare April 25, 2023 22:31
@lsjostro lsjostro changed the title new cloud init disk resource feat: cloud init disk resource Apr 27, 2023
@lsjostro
Copy link
Contributor Author

before merge we prob need the fix in the go-api as well. Telmate/proxmox-api-go#254

@lsjostro
Copy link
Contributor Author

I guess this can be merged then. Will not 100% work in all cases until we get the new reworked disk handling in the go API into this project.

@mleone87 mleone87 merged commit 1d62c50 into Telmate:master May 24, 2023
1 check passed
@bartholdbos bartholdbos mentioned this pull request Aug 2, 2023
@paraglade
Copy link

Note: this update requires Datastore.AllocateTemplate permssions
from the Proxmox user manual:
https://pve.proxmox.com/pve-docs/chapter-pveum.html#_privileges:~:text=Datastore.AllocateTemplate%3A%20allocate/upload%20templates%20and%20ISO%20images

Datastore.AllocateTemplate: allocate/upload templates and ISO images

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

Successfully merging this pull request may close these issues.

None yet

3 participants