ddelnano / packer-plugin-xenserver

A builder plugin for Packer.IO to support building XenServer images.
Mozilla Public License 2.0
74 stars 37 forks source link

Recommended Workflow #110

Closed Shackelford-Arden closed 8 months ago

Shackelford-Arden commented 9 months ago

Hello!

I'm trying to understand the "proper" workflow within XCP-ng/XO to use Packer. I've got a working build using the following (generalized for brevity):

source "xenserver-iso" "fedora_server" {
  iso_checksum = var.iso_checksum
  iso_url      = var.iso_url

  sr_iso_name = var.sr_iso_name
  sr_name     = var.sr_name

  remote_host     = var.remote_host
  remote_password = var.remote_password
  remote_username = var.remote_username

  vm_name         = var.vm_name
  vm_description  = "Build started: ${local.timestamp} This was built using Hashicorp Packer! Port: {{ .HTTPPort }}"
  vcpus_atstartup = 2
  vm_memory       = 4096
  disk_size       = 10240
  firmware        = "uefi"

  http_directory = "http"
  boot_command   = ["<insert_commands_here>"]
  boot_wait      = "15s"

  ssh_username     = var.ssh_user
  ssh_password     = var.ssh_password
  ssh_wait_timeout = "1500s"

  keep_vm           = "always"
  skip_set_template = false
}

As it stands today, this results in a template that I can then use in either the UI or the Terraform provider (haven't used it yet this way, but will soon).

However, once I re-run the Packer build, the build errors out due to naming conflicts:

image

Is the intended pattern here that there is a brand new template created upon each run using a new dynamically generated name?

Seems like that would make this challenging to use w/ the Terraform provider (based on reading the docs for it) since the data resource doesn't have similar functionality to that of AWS's AMI data resource where it attempts to match the name and pulls the most recent. Rather it appears that the name is static, which would then require updating once a new template has been generated.

Based on what I see in the XO UI, seems like there isn't a way to update an existing template?

ddelnano commented 8 months ago

Hey @Shackelford-Arden, sorry for the late reply and appreciate you getting involved with the project!

Is the intended pattern here that there is a brand new template created upon each run using a new dynamically generated name?

Not exactly. What you described with the AWS AMI data source is what I envisioned for the project. However, my personal workflow has been lazy and I never tried to make the workflow you described a reality. I typically build an VM template through packer and rename the template through the Xen Orchestra UI.

screen

It would be very cool to have a more polished workflow, so contributions to make that seamless are extremely welcome.

The idea I had for supporting the workflow you described was to annotate a VM template in a way that the xenorchestra_template could then support filtering by. I don't know exactly how to do this with direct Xenserver integration without some investigation, but if the packer integrated with XO directly XO's tag mechanism would be flexible enough for supporting that (tag could be packer-created-at:${timestamp_of_build}).

As you mentioned, the filtering isn't the only piece that needs work (packer plugin issues with multiple VMs).

Shackelford-Arden commented 8 months ago

Cool, thanks for getting back to me! Makes sense based on what I'm seeing. I'll close this out for now, but I'm hoping to see if I can play with this some more!