Giter Site home page Giter Site logo

ddelnano / packer-plugin-xenserver Goto Github PK

View Code? Open in Web Editor NEW

This project forked from xenserver/packer-plugin-xenserver

71.0 7.0 37.0 18.9 MB

A builder plugin for Packer.IO to support building XenServer images.

License: Mozilla Public License 2.0

Go 99.27% Makefile 0.73%

packer-plugin-xenserver's Introduction

XenServer packer.io builder

This builder plugin extends packer.io to support building images for XenServer.

This is a fork of the original builder since the original project was abandoned and no longer compiled with recent versions of Go or worked with Xenserver 7.6 and later.

It improves the original project in the following ways:

  1. Developed alongside the Xenorchestra terraform provider to ensure the hashicorp ecosystem is interoperable.
  2. Reimplements how the boot commands are sent over VNC to be compatible with later versions of Xenserver (Citrix hypervisor) and XCP

Status

At the time of this writing the packer builder has been verified to work with Xenserver 7.6 and can launch VMs with the packer output through the xenorchestra terraform provider.

The following list contains things that are incomplete but will be worked on soon:

  • The documentation is still in an inconsistent state with upstream
  • XVA builder is untested
  • Lots of dead code to remove from upstream

Using the builder

The packer builder can be installed via packer init as long as the packer template includes the following in it's pkr.hcl file

packer {
  required_plugins {
   xenserver= {
      version = ">= v0.6.0"
      source = "github.com/ddelnano/xenserver"
    }
  }
}

The following command will install the packer plugin using the Ubuntu example provided in this repository.

packer init examples/ubuntu/ubuntu-2004.pkr.hcl

If you are using an older version of packer or are still using json templates you will need to download the relevant release from the project's releases page and copy the binary to ~/.packer.d/plugins/packer-builder-xenserver-iso.

Developing the builder

Dependencies

  • Packer >= v1.7.1 (https://packer.io)
  • XenServer / Citrix Hypervisor > 7.6
  • Golang 1.20

Compile the plugin

Once you have installed Packer, you must compile this plugin and install the resulting binary.

Documentation for Plugins directory: Official Docs

Linux/MacOS

go build -o packer-plugin-xenserver

# Add the plugin to the location packer expects it to be installed in
mkdir -p ~/.packer.d/plugins/
cp packer-plugin-xenserver  ~/.packer.d/plugins

Windows (Powershell)

go build -o packer-plugin-xenserver

mkdir "%APPDATA%\packer.d\plugins"
cp packer-plugin-xenserver  "%APPDATA%\packer.d\plugins"

Documentation

For complete documentation on configuration commands, see the xenserver-iso docs

Support

You can discuss any issues you have or feature requests in Discord.

If you'd like to support my effort on the project, please consider buying me a coffee

"Buy Me A Coffee"

packer-plugin-xenserver's People

Contributors

4censord avatar arnaudcharles avatar ataxyanetwork avatar bmeach avatar chengsun avatar ddelnano avatar dependabot[bot] avatar ebrainte avatar hcoyote avatar heindsight avatar jonludlam avatar kongslund avatar liath avatar makunterry avatar mboutet avatar melck avatar mmahnic avatar rdobson avatar ringods avatar shackelford-arden avatar somerandomqaguy avatar zhengchai avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

packer-plugin-xenserver's Issues

ISO's are deployed to SR instead of SR_ISO

Attached is the default template I am using to deploy a CentOS8 ISO to my SR and then build the machines. I have 2 issues:

  1. The ISO is copied to my SR and NOT my SR_ISO
  2. It creates a duplicate ISO every time

I have attached 2 screenshots of each SR I have showing the issue at hand along with the configuration file I used to deploy the CentOS 8 image.

I am using this script to execute the centos8.json file (IP, username, and password masked):

# Export variables for the script
echo writing variables...

export XAPI_HOST='10.xxx.xxx.xxx'
export XAPI_USERNAME='username'
export XAPI_PASSWORD='***************'

echo starting deployment...
PACKER_LOG=1 packer build -debug --var sr_name='Equallogic 10k SAS - HQ2' --var sr_iso_name='ISOs - HQ2' centos8.json

SR_ISO showing a lack of the centos8 ISO being uploaded

SR showing multiple uploads of the same ISO

centos8.txt

Let users choose if they want a template or a full VM

Currently, if we use the packer plugin “as is”, the provider will output an XVA file which is an exported VM with the template field set to “true”.
In the case of an XVA template, we can “just” reimport it as a template for Xen Orchestra, and then use it to create a VM.
For some reason, anyone might want to generate a VM which is NOT a template, so you can import the XVA and run it immediately.

My current workaround is to comment new(xscommon.StepSetVmToTemplate) in the file builder.go, rebuild the provider, and use it.

So, I would like to have a nice packer variable to switch easily between the “XVA template” and the “XVA VM”

I have in mind the steps to achieve this, but since I'm not a good Go developer, I can't have it work as I wish
My idea is to:

  • Have a pkr variable “set_template” that we can set as true or false (so far, I'm able to do that)
  • Then, in the builder.go, have something like:
//new(xscommon.StepSetVmToTemplate),
&xscommon.StepConvertToTemplate{
        if self.config.SetTemplate == true {
            // exectute the step to convert the VM as a template
            new(xscommon.StepSetVmToTemplate)
        }
        //else do nothing
    },

And this is the part where I can't get it to work.

Maybe it can be done in another way, but, as I said, go is not (yet) my best friend :D

@ddelnano can I have your opinion about this ?

packer examples/ubuntu/ubuntu-2004.pkr.hcl

Hi, i'm trying to use the packer example you have provided but i always get the the autoinstall prompt. Tried it totally vanilla, just with creds to my xcp-ng host. If i provied it with yes it runs trough the example and completes without any issues.

Currently i'm using XCP-NG 8.2.1 and packer 1.8.0
Screenshot 2022-08-03 at 15 47 10

Have anyone else experienced this?

Xenserver-iso no longer working with packer 1.7

With the new packer version 1.7 came some changes to the plugin infrastucture.
attempting to use the xenserver-iso builder with packer 1.7 results in this error.

Error: Failed to load source type
The protocol of this plugin (protocol version 4 and lower) was deprecated,
please use a newer version of this plugin.Or use an older version of Packer (pre
1.7) with this plugin.

looking at
https://www.packer.io/docs/plugins#installing-plugins
plugins are now beeing declared directly in the packer files.
and the packer-builder-xenserver-iso naming sheme is beeing deprecated in favor of something like
packer-plugin-xenserver as a multi-plugin binary

Canceled build still waits for connection timeout

While testing the examples I supplied the wrong ip address for my xcp-ng, so i canceled the build.

After Cancelling build after receiving interrupt packer still waits for the connection attempt to time out before terminating.

To Reproduce:

  • give packer an valid IPaddress at which no xenserver is running
  • start the build and cancel the build
  • wait for the connection to timeout
xenserver-iso.centos8-netinstall: output will be in this color.

Cancelling build after receiving interrupt
Build 'xenserver-iso.centos8-netinstall' errored after 2 minutes 8 seconds: Post "https://<sensitive>": dial tcp <sensitive>:443: connect: connection timed out

==> Wait completed after 2 minutes 8 seconds
Cleanly cancelled builds after being interrupted.

Fix problem with packer's shutdown command when finished building

From a discussion in Discord, the shutdown command will fail to run and then packer will force a shutdown. WeirdAlJazeera reported that the following fixed the shutdown issue for them (discord link)

Sounds good to me. Here's the git diff. I'm just worried that I'm butting two completely different ways of performing this kind of operation together in a weird way:


diff --git a/builder/xenserver/common/step_shutdown.go b/builder/xenserver/common/step_shutdown.go
index 2cafad3..1c524aa 100644
--- a/builder/xenserver/common/step_shutdown.go
+++ b/builder/xenserver/common/stepshutdown.go
@@ -7,12 +7,14 @@ import (

        "github.com/hashicorp/packer-plugin-sdk/multistep"
        "github.com/hashicorp/packer-plugin-sdk/packer"
+       packersdk "github.com/hashicorp/packer-plugin-sdk/packer"
        xenapi "github.com/terra-farm/go-xen-api-client"
 )

 type StepShutdown struct{}

 func (StepShutdown) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction {
+       comm := state.Get("communicator").(packersdk.Communicator)
        config := state.Get("commonconfig").(CommonConfig)
        ui := state.Get("ui").(packer.Ui)
        c := state.Get("client").(*Connection)
@@ -31,8 +33,9 @@ func (StepShutdown) Run(ctx context.Context, state multistep.StateBag) multistep
                if config.ShutdownCommand != "" {
                        ui.Message("Executing shutdown command...")

-                       , err := ExecuteGuestSSHCmd(state, config.ShutdownCommand)
-                       if err != nil {
+                       // _, err := ExecuteGuestSSHCmd(state, config.ShutdownCommand)
+                        cmd := &packersdk.RemoteCmd{Command: config.ShutdownCommand}
+                       if err:= cmd.RunWithUi(ctx, comm, ui); err != nil {
                                ui.Error(fmt.Sprintf("Shutdown command failed: %s", err.Error()))
                                return false
                        }

I will need to verify that this fixes the shutdown issues and then review the change more closely to see how it's addressing the shutdown error.

xenserver-iso.ubuntu-2004: Error detecting local IP: ssh: handshake failed

Hello. Any time I tried to build vm (ubuntu and centos) I got the same error:
xenserver-iso.ubuntu-2004: Error detecting local IP: ssh: handshake failed

2021/11/21 05:47:34 packer-plugin-xenserver_v0.3.2_x5.0_linux_amd64 plugin: 2021/11/21 05:47:34 Attached VDI 'e738461b-5d42-4471-9b5d-dcbe28095b34'
2021/11/21 05:47:37 ui: �[1;32m==> xenserver-iso.ubuntu-2004: Step: Set SSH address to VM host IP�[0m
2021/11/21 05:47:37 ui: �[1;32m==> xenserver-iso.ubuntu-2004: Set host SSH address to '<sensitive>'.�[0m
2021/11/21 05:47:37 ui: �[1;32m==> xenserver-iso.ubuntu-2004: Unpausing VM 41dc3e4f-f9be-9dd6-0baa-d2fa79ec9ba4�[0m
2021/11/21 05:47:37 ui: �[1;32m==> xenserver-iso.ubuntu-2004: Waiting 10s for boot...�[0m
2021/11/21 05:47:47 ui: �[1;32m==> xenserver-iso.ubuntu-2004: Connecting to the VM console VNC over xapi via <sensitive>�[0m
2021/11/21 05:47:47 ui: �[1;32m==> xenserver-iso.ubuntu-2004: Making HTTP request to initiate VNC connection: CONNECT /console?uuid=0de15564-b473-d884-efc9-7de9b9ab2f37 HTTP/1.0
==> xenserver-iso.ubuntu-2004: Host: <sensitive>
==> xenserver-iso.ubuntu-2004: Cookie: session_id=OpaqueRef:c44a7a32-5d2d-497a-baec-b278154c5aa2
==> xenserver-iso.ubuntu-2004: 
==> xenserver-iso.ubuntu-2004:�[0m
2021/11/21 05:47:47 ui: �[1;32m==> xenserver-iso.ubuntu-2004: Received response: HTTP/1.1 200 OK
==> xenserver-iso.ubuntu-2004: Connection: keep-alive
==> xenserver-iso.ubuntu-2004: Cache-Control: no-cache, no-store
2021/11/21 05:47:47 packer-plugin-xenserver_v0.3.2_x5.0_linux_amd64 plugin: 2021/11/21 05:47:47 Connected to the VNC console: QEMU
2021/11/21 05:47:47 ui error: �[1;31m==> xenserver-iso.ubuntu-2004: Error detecting local IP: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none], no supported methods remain�[0m
2021/11/21 05:47:47 ui: �[1;32m==> xenserver-iso.ubuntu-2004: Deleting output directory...�[0m
2021/11/21 05:47:47 [INFO] (telemetry) ending xenserver-iso.ubuntu-2004
2021/11/21 05:47:47 ui error: �[1;31mBuild 'xenserver-iso.ubuntu-2004' errored after 30 seconds 855 milliseconds: Build was halted.�[0m
2021/11/21 05:47:47 Waiting on builds to complete...
2021/11/21 05:47:47 ui: 
==> Wait completed after 30 seconds 856 milliseconds
2021/11/21 05:47:47 machine readable: error-count []string{"1"}
2021/11/21 05:47:47 ui error: 
==> Some builds didn't complete successfully and had errors:
2021/11/21 05:47:47 machine readable: xenserver-iso.ubuntu-2004,error []string{"Build was halted."}
2021/11/21 05:47:47 ui error: --> xenserver-iso.ubuntu-2004: Build was halted.
2021/11/21 05:47:47 ui: 
==> Builds finished but no artifacts were created.

May be this error forced by using bond network on my xenserver

Clarification on keep_vm, format, output_directory, and sr_name.

I have experimented with this plugin for several days now and after reading through the documentation, I am still confused on the exact functionality of keep_vm, format, output_directory, and sr_name.

To begin, I was under the impression that the sr_name provided the storage repository where the resulting files would be stored. If that is the case, what is the need for an output directory on the local machine? Are these two functionalities mutually exclusive, meaning, either you create a template OR you store the resulting XVA?

Additionally, is the logic for keep_vm reversed? Or am I missing something? It seems that if keep_vm=on_success is set, and the creation of the template is successful, the vm is actually deleted. Does "keeping" refer to downloading the XVA as opposed to keeping a template? Is this better names "keep_template"?

The documentation states that keep_vm=on_success "requests that the VM only be cleaned up if an artifact was produced. The latter is useful for debugging templates that fail." Wouldn't it make sense that you would keep the vm on failure? This wording confuses me.

Lastly, for the format setting, the documentation states, "Set to "none" to export nothing; this is only useful with "keep_vm" set to "always" or "on_success"." If keeping the vm means downloading it to the local machine at the output_directory, why would you every set the format to "none"?

Once these points are clarified, I would be more that willing to help update the documentation so that the next newbie is not as confused.

Boot command fails; Error detecting local IP: ssh: handshake failed

Whenever we input a boot_command (to press a button in UEFI BIOS to start the attached disk) we get a failure;

==> xenserver-iso.win10: Step: Set SSH address to VM host IP
==> xenserver-iso.win10: Set host SSH address to '1.1.1.1.
==> xenserver-iso.win10: Unpausing VM 37249b69-da92-4042-ea5b-f54670b5c27a
==> xenserver-iso.win10: Waiting 5s for boot...
==> xenserver-iso.win10: Connecting to the VM console VNC over xapi via 1.1.1.1
==> xenserver-iso.win10: Making HTTP request to initiate VNC connection: CONNECT /console?uuid=ce5fd319-72b4-2b36-b773-5adb44507ef6 HTTP/1.0
==> xenserver-iso.win10: Host: 1.1.1.1
==> xenserver-iso.win10: Cookie: session_id=OpaqueRef:7996cbe2-0e1e-43c3-b780-f58c4d6f28d2
==> xenserver-iso.win10:
==> xenserver-iso.win10:
==> xenserver-iso.win10: Received response: HTTP/1.1 200 OK
==> xenserver-iso.win10: Connection: keep-alive
==> xenserver-iso.win10: Cache-Control: no-cache, no-store
==> xenserver-iso.win10:
==> xenserver-iso.win10:
==> xenserver-iso.win10: Error detecting local IP: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none password], no supported methods remain`

It seems like it's trying to SSH to the host and gives up (certainly the intent could not be to SSH to a machine before it even has an OS installed). The ssh_username/password fields do not help and do not even seem to affect the behavior. If the boot_command is removed entirely and we use BIOS (or hit spacebar in bios ourselves) the entire build is fine.

Recommended Workflow

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?

centos and ubuntu demo files do not install xentools

Modify the ks-centos8.cfg (centos) and user-data (ubuntu) files to include the installation of xentools.

The plugin mounts the guest-tools.iso in DVD Drive 2 but the scripts for mounting and installing the tools arent part of the deployment.

The xva builder isn't working

The xva builder is currently not tested and doesn't seem to work
packer currently doesn't recognize xenserver-xva as a valid source
this can be seen with the minimal configuration

source "xenserver-xva" "cloudinit-base" {
}
build {
  sources = ["sources.xenserver-xva.cloudinit-base"]
}

packer validate currently errors with
Error: Unknown source type xenserver-xva

I assume it would need to be declared in packer.json?

  • get packer to recognize xenserver-xva
  • get an example working
  • check and/or write tests
  • document the xva builder

plugin compile instructions incorrect?

Plugin compile instructions in the README -

$ go build -o packer-plugin-xenserver

# Add the builder to the location packer expects it to be installed in
$ mkdir -p ~/.packer.d/plugins/
$ cp builder-xenserver-iso  ~/.packer.d/plugins/packer-builder-xenserver-iso

Should that last line be as follows?

...
$ cp packer-plugin-xenserver ~/.packer.d/plugins/packer-builder-xenserver-iso
...

Update builder documentation to include the missing (boot) `firmware` parameter

Please add the option to select between bios and uefi boot firmware for the VM.

This could initially be added as an option to platform_args. This could then be migrated to a standalone argument later.

Perhaps could be implemented in:

File: https://github.com/ddelnano/packer-plugin-xenserver/blob/master/builder/xenserver/iso/builder.go

Line 84:

	if len(self.config.PlatformArgs) == 0 {
		pargs := make(map[string]string)
		pargs["viridian"] = "false"
		pargs["nx"] = "true"
		pargs["pae"] = "true"
		pargs["apic"] = "true"
		pargs["timeoffset"] = "0"
		pargs["acpi"] = "1"
		self.config.PlatformArgs = pargs
	}

add an additional option such as:

		pargs["hvm_boot_firmware"] = "bios"

Which would match parameter in https://github.com/terra-farm/terraform-provider-xenorchestra/blob/master/xoa/resource_xenorchestra_vm.go

Crash when lauching packer build only with 0.7.2

Hello
i'm trying to use packer with XCP-NG (already use it with VMware)
When i try a simple packer build i have a crash :
panic: ConfigSpec failed: gob: type cty.Type has no exported fields [recovered] panic: ConfigSpec failed: gob: type cty.Type has no exported fields

I have tried on a Windows machine with packer 1.8.4 and on linux with the latest packer release and it's the same
Don't know where to start, anyone can help ?
thanks

Ubuntu needs its autoinstall config Typed twice

In the #7 (examples/ubuntu/ubuntu-2004.pkr.hcl)
the boot command types the autoinstall config twice.

  boot_command   = [
    "<esc><f6> autoinstall ds=nocloud-net;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/<enter><wait>",
    "<f6><wait><esc><wait> autoinstall ds=nocloud-net;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/<enter><wait>"
  ]

I does not currently work otherwise.

I tested this and both boot commands are required to work. So ignore this comment.
This should be a bug, but is definitely outside the scope updating these examples to use HCL.
Originally posted by @ddelnano in #7 (comment)

Update to packer-sdc command for validating plugin compatibility

👋 Fellow Packer maintainer here, reaching out to inform you about an upcoming breaking change that will affect your goreleaser release pipeline. In Packer 1.8.0 we will remove the packer-plugin-check command in Packer core in favor of the packer-sdc plugin-check command from the Packer Plugin SDK. So calling go install github.com/hashicorp/packer/cmd/packer-plugins-check@latest will result in an error.

To avoid potential issues I recommend either pinning the packer-plugins-check command to the current version of Packer until you can move to the packer-sdc command

go install github.com/hashicorp/packer/cmd/[email protected]

Or you can update your release configuration to use the packer-sdc command, which is the preferred long-term solution.

I'v provided a link to the updates that were made to the Packer Plugin Scaffolding for using the packer-sdc command here

Please let me know if you have any questions.

ISO Upload - Even is the ISO exists it is uploaded

If you run the same build multiple times, the iso is uploaded even if it already exists. If a check was put in place to check for the existence of the iso first it would speed up the build process when testing.

Allow users to install the packer plugin with `packer init`

Now that we've upgraded to the packer-plugin-sdk, we should be able to allow users to install it with packer init. I had difficulty getting this to work during #13 but this should be the supported way for installing the plugin in recent versions of packer.

[ISO-Builder] Cleanup fails on Step: Wait for VM's IP to become known to us.

if a build is aborted in the
==> xenserver-iso.centos: Step: Wait for VM's IP to become known to us.
stage, packer terminates without cleaning up the vm

To reproduce:
start one ofh the example builds,
send a SIGTERM (ctrl+c) once
==> xenserver-iso.cloudinit-base: Step: Wait for VM's IP to become known to us.
apears

boot_command appears to lose vnc connection on guest reboot

I have a boot_command that spans a guest reboot. Basically it is performing an installation, restarting the machine, awaiting it to come back up and continuing after it initialized its state.
The work cannot be done before reboot as the environment for that is not yet set-up.

Despite generous <wait> applied, the boot_command cannot complete. One indication that it is VNC related is that the console is no longer locked exclusively in XO, meaning while packer is still typing, the rebooted guest's console is already visible in XO.
A similar packer configuration against vsphere runs through, i.e. there the boot_command is continued with the rebooted guest.

Cannot recreate template if old one (with same name) still exists

I want to use this packer plugin to create a golden template such that the same of the template is "ubuntu-golden". This template creation fails if a template of the same name already exists. However, XCP-NG does allow multiple templates of the same name to exist. In other words, this limitation (while it may or may not be good practice) is imposing a limitation that XCP-NG does not impose.

My suggestion is to change line 46 of https://github.com/ddelnano/packer-plugin-xenserver/blob/main/builder/xenserver/common/step_type_boot_command.go to find the VM by the UUID instead of by name. The UUID is already used in pausing and unpausing the VM (like on line 24 of https://github.com/ddelnano/packer-plugin-xenserver/blob/main/builder/xenserver/common/step_start_vm_paused.go).

If people still want to avoid allowing this by default, we could introduce a new config flag, such as, "allow_duplicate_templates=false".

Feature request: Add <waitXX> in boot_command

Sometimes things take time, repeating 10s waits in boot_command is tiresome.
Other packer plugins support <waitXX>, with the following semantics:

<waitXX> - Add an arbitrary pause before sending any additional keys. 
The format of XX is a sequence of positive decimal numbers, each with optional fraction and a unit suffix, such as 300ms, 1.5h or 2h45m. 
Valid time units are ns, us (or µs), ms, s, m, h. For example <wait10m> or <wait1m20s>.

E.g. https://www.packer.io/docs/builders/qemu.html#lt-waitxx-gt-

Would be great to see this in this plugin as well.

When using the Packer HCL required plugins stanza getting an error where the 256SUM is not found

packer.hcl file

packer {
required_plugins {
xenserver= {
version = ">= v0.4.0"
source = "github.com/ddelnano/xenserver"
}
}
}

RUNTIME ERROR

could not get sha256 checksum file for github.com/ddelnano/xenserver version 1.0.0. Is the file present on the release and correctly named ? GET https://github.com/ddelnano/packer-plugin-xenserver/releases/download/v1.0.0/packer-plugin-xenserver_v1.0.0_SHA256SUMS: 404 []

building image...
Error: no plugin installed for github.com/ddelnano/xenserver >= v0.4.0

New release ?

Several nice merge requests has been merged since last release - maybe it's time to cut a new one ?

Ubuntu doesnt work without insanly high timeout and ssh_handshake_attempts

This timeout was lowered from the previous 60000s value and the ssh_handshake_attempts (which was set to 10000) was removed. This is causing the ubuntu example to fail with the following error

ddelnano@ddelnano-desktop:~/go/src/github.com/xenserver/packer-builder-xenserver$ packer1.7.1 build examples/ubuntu/ubuntu-2004.pkr.hcl
xenserver-iso.ubuntu-2004: output will be in this color.

==> xenserver-iso.ubuntu-2004: XAPI client session established
==> xenserver-iso.ubuntu-2004: Retrieving ISO
==> xenserver-iso.ubuntu-2004: Trying http://releases.ubuntu.com/20.04/ubuntu-20.04.2-live-server-amd64.iso
==> xenserver-iso.ubuntu-2004: Trying http://releases.ubuntu.com/20.04/ubuntu-20.04.2-live-server-amd64.iso?checksum=d1f2bf834bbe9bb43faf16f9be992a6f3935e65be0edece1dee2aa6eb1767423
==> xenserver-iso.ubuntu-2004: http://releases.ubuntu.com/20.04/ubuntu-20.04.2-live-server-amd64.iso?checksum=d1f2bf834bbe9bb43faf16f9be992a6f3935e65be0edece1dee2aa6eb1767423 => /home/ddelnano/go/src/github.com/xenserver/packer-builder-xenserver/packer_cache/dc8718d65b80640808a10b87f6d44fc2d16420af
==> xenserver-iso.ubuntu-2004: Starting HTTP server on port 8000
==> xenserver-iso.ubuntu-2004: Step: Upload VDI 'ubuntu-20.04.2-live-server-amd64.iso'
==> xenserver-iso.ubuntu-2004: Step: Found SRs '[OpaqueRef:beeed204-90ff-4f11-bfe2-1dfbb46d5eb5 OpaqueRef:ac11b102-c83c-4b0a-b076-2b5050474ac0 OpaqueRef:a6aca570-c039-4d21-8f2c-16c38456bdfd OpaqueRef:9963d6b4-d507-4425-90e6-2d857a25c4d0 OpaqueRef:90bdec93-5ba1-4187-bedd-5f18d3318410 OpaqueRef:10e7e21a-0569-4e6c-931e-d295a76a3be0]'
==> xenserver-iso.ubuntu-2004: PUT 'https://<sensitive>/import_raw_vdi?session_id=OpaqueRef%3A3a09798d-ccea-4da0-a069-3090f0dd42e2&task_id=OpaqueRef%3Ad5bae3ea-cf5d-4bf4-8dcd-f0089e966877&vdi=OpaqueRef%3Ada7653a0-d1d0-48fc-a777-11866f19fa56'
==> xenserver-iso.ubuntu-2004: Step: Create Instance
==> xenserver-iso.ubuntu-2004: Using the following SR for the VM: OpaqueRef:10e7e21a-0569-4e6c-931e-d295a76a3be0
==> xenserver-iso.ubuntu-2004: Created instance 'a16a1de7-eaee-c035-a349-add74a2018bd'
==> xenserver-iso.ubuntu-2004: Step: Start VM Paused
==> xenserver-iso.ubuntu-2004: Step: Set SSH address to VM host IP
==> xenserver-iso.ubuntu-2004: Set host SSH address to '192.168.88.89'.
==> xenserver-iso.ubuntu-2004: Unpausing VM a16a1de7-eaee-c035-a349-add74a2018bd
==> xenserver-iso.ubuntu-2004: Waiting 10s for boot...
==> xenserver-iso.ubuntu-2004: Connecting to the VM console VNC over xapi via 192.168.88.89
==> xenserver-iso.ubuntu-2004: Making HTTP request to initiate VNC connection: CONNECT /console?uuid=1e2a424b-b302-c212-a489-b177c49580f5 HTTP/1.0
==> xenserver-iso.ubuntu-2004: Host: 192.168.88.89
==> xenserver-iso.ubuntu-2004: Cookie: session_id=OpaqueRef:3a09798d-ccea-4da0-a069-3090f0dd42e2
==> xenserver-iso.ubuntu-2004:
==> xenserver-iso.ubuntu-2004:
==> xenserver-iso.ubuntu-2004: Received response: HTTP/1.1 200 OK
==> xenserver-iso.ubuntu-2004: Connection: keep-alive
==> xenserver-iso.ubuntu-2004: Cache-Control: no-cache, no-store
==> xenserver-iso.ubuntu-2004:
==> xenserver-iso.ubuntu-2004:
    xenserver-iso.ubuntu-2004: Found local IP: 192.168.88.254
==> xenserver-iso.ubuntu-2004: Typing boot commands over VNC...
==> xenserver-iso.ubuntu-2004: Finished typing.
==> xenserver-iso.ubuntu-2004: Step: Wait for VM's IP to become known to us.
    xenserver-iso.ubuntu-2004: Got IP '192.168.88.26' from HTTP request
==> xenserver-iso.ubuntu-2004: Got IP address '192.168.88.26'
==> xenserver-iso.ubuntu-2004: Creating a local port forward over SSH on local port 5900
==> xenserver-iso.ubuntu-2004: Port forward setup. 5900 ---> 192.168.88.26:22 on 192.168.88.89
==> xenserver-iso.ubuntu-2004: Using ssh communicator to connect: 192.168.88.26
==> xenserver-iso.ubuntu-2004: Waiting for SSH to become available...
==> xenserver-iso.ubuntu-2004: Error waiting for SSH: Packer experienced an authentication error when trying to connect via SSH. This can happen if your username/password are wrong. You may want to double-check your credentials as part of your debugging process. original error: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none password], no supported methods remain
==> xenserver-iso.ubuntu-2004: Deleting output directory...
Build 'xenserver-iso.ubuntu-2004' errored after 5 minutes 24 seconds: Packer experienced an authentication error when trying to connect via SSH. This can happen if your username/password are wrong. You may want to double-check your credentials as part of your debugging process. original error: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none password], no supported methods remain

I have not tested if adding the ssh_handshake_attempts is enough to get it working, but I was able to verify using the previous values work.

While it's crappy to have those values set very high to get the example to work, I think we should keep the values as is (unless you want to investigate setting them more properly now).

Originally posted by @ddelnano in #7 (comment)

[FEATURE REQUEST] Add ability to provide content directly to floppy_files and http_directory

I dont know how possible this would be but I would really like to be able to provide content directly to the files hosted either in the http_directory setting or the floppy_files setting. Im thinking something very similar to the Packer Builder for VMware vSphere http_content setting for example this works in their config.

  http_content = {
    "/a/b"     = file("http/b")
    "/foo/bar" = templatefile("${path.root}/preseed.cfg", { packages = ["nginx"] })
  }

I would like to be able to create a image per app/env that I have without having to do it in terraform. For example I would like to pass my generated vm name into the user-data file when the image is built so the template images hostname is descriptive and can use variables like the time it was started. Terraform would then take care of changing the hostname per vm when it runs post packer? Is this possible to be implemented or should I look down another road like having a preseed python script that generates the files via j2 or something similar?

Support changes of IP address on reboot of VM

When using packer in combination with this plugin, to create images of certain operating systems such as Debian, I am having the following issue:

I am using the Debian 11.6.0 netinst iso to install Debian via network mirrors. This means that the VM retrieves an IP address very early during the installation process, which this packer plugin notices. However, when the VM restarts after a successful installation of the OS, the IP address for the VM tends to change, since there is a change in the DHCP client ID. I am inclined to believe that Debian isn't the only OS that would have this issue.

Therefore, I think it would be beneficial for this plugin to be able to react to changes of the IP address for the VM. If the HTTP server is used to detect the IP address for the VM, it would be up to the user to perform an HTTP request to the HTTP server when the IP address has changed. Otherwise, the plugin should continuously check whether the IP address has changed by means of the xe-guest-utilities package on the VM.

Problems running packer against deployments with a large number of hosts

I'm trying to use packer-builder-xenserver with XCP-ng 7.6 and 8.0, using the provided ubuntu 20.04 example (had to update the json file to use Ubuntu 20.04.2 instead of 20.04.1).

Unfortunately, testing in both XCP-ng versions, the build encounters an error trying to open the VNC session, as shown below. I'm using packer version 1.6.6, tested both in Ubuntu 18.04 and MacOS Big Sur.

Debug mode enabled. Builds will not be parallelized.
xenserver-iso: output will be in this color.

==> xenserver-iso: XAPI client session established
==> xenserver-iso: Starting HTTP server on port 8000
==> xenserver-iso: Step: Create Instance
==> xenserver-iso: Using the following SR for the VM: OpaqueRef:eac24214-9929-4fbc-b146-3e006d5e3b0f
==> xenserver-iso: Created instance '5e5b9288-490e-afec-1246-8bdf0435829a'
==> xenserver-iso: Step: Start VM Paused
==> xenserver-iso: Step: Set SSH address to VM host IP
==> xenserver-iso: Set host SSH address to '172.31.16.93'.
==> xenserver-iso: Unpausing VM 5e5b9288-490e-afec-1246-8bdf0435829a
==> xenserver-iso: Waiting 10s for boot...
==> xenserver-iso: Connecting to the VM console VNC over xapi
==> xenserver-iso: Making HTTP request to initiate VNC connection: CONNECT /console?uuid=0f1ca5fb-8ee1-2050-cc05-aaf8f436b789 HTTP/1.0
==> xenserver-iso: Cookie: session_id=OpaqueRef:d6ceda20-01cc-479a-b699-03136f2b59ed
==> xenserver-iso:
==> xenserver-iso:
==> xenserver-iso: Received response: HTTP/1.0 500 Internal Error
==> xenserver-iso: content-length: 246
==> xenserver-iso: content-type:text/html
==> xenserver-iso: connection:close
==> xenserver-iso: cache-control:no-cache, no-store
==> xenserver-iso:
==> xenserver-iso: <html><body><h1>HTTP 500 internal server error</h1>An unexpected error occurred; please wait a while and try again. If the problem persists, please contact your support representative.<h1> Additional information </h1>Console.Failure</body></html>
==> xenserver-iso: Error establishing VNC session: EOF
==> xenserver-iso: Deleting output directory...
Build 'xenserver-iso' errored after 20 seconds 240 milliseconds: Error establishing VNC session: EOF

==> Wait completed after 20 seconds 240 milliseconds

==> Some builds didn't complete successfully and had errors:
--> xenserver-iso: Error establishing VNC session: EOF

==> Builds finished but no artifacts were created.

XCP-ng console shows the following error in xensource.log:

Mar  1 11:11:43 server2 xapi: [error|server2|12127597 INET :::80|Connection to VM console R:d1a466e33c00|console] VM OpaqueRef:f5710702-48a5-4f8c-9075-41dcf11d8cc6 (Console OpaqueRef:c4e0a5bd-d49e-442b-ad72-f52e741da145) has resident_on = OpaqueRef:206f7cf6-9d76-43b3-92ce-eeda190b5728 <> localhost
Mar  1 11:11:43 server2 xapi: [error|server2|12127597 INET :::80||backtrace] Connection to VM console R:d1a466e33c00 failed with exception Console.Failure
Mar  1 11:11:43 server2 xapi: [error|server2|12127597 INET :::80||backtrace] Raised Console.Failure
Mar  1 11:11:43 server2 xapi: [error|server2|12127597 INET :::80||backtrace] 1/1 xapi @ server2 Raised at file (Thread 12127597 has no backtrace table. Was with_backtraces called?, line 0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.