hetznercloud / packer-plugin-hcloud

Packer plugin for Hetzner Cloud Builder
https://developer.hashicorp.com/packer/integrations/hetznercloud/hcloud
Mozilla Public License 2.0
25 stars 21 forks source link

Allow Hetzner Snapshots as base for a Snapshot build #31

Closed Nkmol closed 2 years ago

Nkmol commented 2 years ago

Community Note

Please vote on this issue by adding a đź‘Ť reaction to the original issue to help the community and maintainers prioritize this request. Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request. If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Description

Allow the possibility to apply a snapshot name as the input of a snapshot build. Currently, we only allow for a "OS image" as the base.

Snapshot selection in Hetzner UI Server creation

Use Case(s)

This would allow for sequential snapshot build, for example with the following chain: ISO Image Ubuntu → Snapshot server → snapshot server-special

Using the Source Build block, I believe, we could even build this chain as Packer build builds in-order of definition.

Potential configuration

There is no difference between 'input' and 'output' definitions, but maybe “base” (so “base_snapshot”) would be applicable both for images and snapshots.

source "hcloud" "server" {
  snapshot_name        = "server-special"
  server_type          = "cx11"
}

source "hcloud" "server-special" {
  snapshot_name        = "server-special"
  server_type          = "cx11"
}

build {
  sources = [
    "source.server"
  ]

  // ...
}

build {
  sources = [
    "source.server-special",
  ]

  source "hcloud.server-special" {
    base_snapshot         = "server"
  }
}

Potential References

Nkmol commented 2 years ago

This is actually possible using the image_filter property, once you make sure to add a snapshot_labels as Snapshots do not have a "name" property.

Which is exactly what is described in the docs:

If you want to reference the image as a sample in your terraform configuration please use the image id or the snapshot_labels.