xenserver / packer-plugin-xenserver Goto Github PK
View Code? Open in Web Editor NEWA builder plugin for Packer.IO to support building Citrix Hypervisor images.
License: Mozilla Public License 2.0
A builder plugin for Packer.IO to support building Citrix Hypervisor images.
License: Mozilla Public License 2.0
First, I want to thank everyone involved with this project. I am so close to being able to automate my XenServer VM build process. However, after successfully building and shutting down the VM, the packer build
process never completes. I'm running on Debian 8 with Go 1.3.3 linux/amd64. My target XenServer version is 6.2.
packer build
output: https://gist.github.com/lgw4/83fa958b6f75823b6cc6
Packer template: https://gist.github.com/lgw4/94de124dc60c961087d3
Kickstart file: https://gist.github.com/lgw4/34876ac51baff283050b
Thank you in advance for any ideas on how I can correct this.
I don't foresee any big issues, but we do want to test Packer to see whether it can run locally in dom0.
In case this works, we should add a remote_type
config (see e.g. https://www.packer.io/docs/builders/vmware-iso.html#remote_type), so that there is no need to specify things like remote_host
when running locally.
Hello,
I seem to be stuck at at the following step.
xenserver-iso: Step: Wait for VM's IP to become known to us.
I have not been able to progress past this part of the process.
I have configured the VM to have an IP.
But the builder just sits there till it times out.
What am I missing?.
For security reasons, we'd like to avoid transmitting XenServer credentials in the clear. It looks like under the hood this project is using the Go standard library's http implementation, which supports https.
Are there any objections to adding a remote_url
config flag, so that users can specify http/https according to their needs? It looks like the value of remote_url
could simply be passed in to XenAPIClient, and could default to "http://${remote_host}" (the current behavior).
Currently, the user must specify the network_uuid and the storage_uuid.
We should:
Hi,
I'm trying to build on Ubuntu 16.04. I get the following:
root@gary-VirtualBox:/usr/local/go/src/github.com/rdobson/packer-builder-xenserver# ./build.sh
==> Removing old directory...
Number of parallel builds: 1
--> linux/amd64: github.com/rdobson/packer-builder-xenserver/plugin/builder-xenserver-xva
--> linux/amd64: github.com/rdobson/packer-builder-xenserver/plugin/builder-xenserver-iso
2 errors occurred:
--> linux/amd64 error: exit status 1
Stderr: plugin/builder-xenserver-xva/main.go:5:2: cannot find package "github.com/xenserver/packer-builder-xenserver/builder/xenserver/xva" in any of:
/usr/local/go/src/github.com/rdobson/packer-builder-xenserver/vendor/github.com/xenserver/packer-builder-xenserver/builder/xenserver/xva (vendor tree)
/usr/local/go/src/vendor/github.com/xenserver/packer-builder-xenserver/builder/xenserver/xva
/usr/local/go/src/github.com/xenserver/packer-builder-xenserver/builder/xenserver/xva (from $GOROOT)
/root/work/src/github.com/xenserver/packer-builder-xenserver/builder/xenserver/xva (from $GOPATH)
--> linux/amd64 error: exit status 1
Stderr: plugin/builder-xenserver-iso/main.go:5:2: cannot find package "github.com/xenserver/packer-builder-xenserver/builder/xenserver/iso" in any of:
/usr/local/go/src/github.com/rdobson/packer-builder-xenserver/vendor/github.com/xenserver/packer-builder-xenserver/builder/xenserver/iso (vendor tree)
/usr/local/go/src/vendor/github.com/xenserver/packer-builder-xenserver/builder/xenserver/iso
/usr/local/go/src/github.com/xenserver/packer-builder-xenserver/builder/xenserver/iso (from $GOROOT)
/root/work/src/github.com/xenserver/packer-builder-xenserver/builder/xenserver/iso (from $GOPATH)
Does anyone know what this is?
Think about how to do tests that actually test something.
We still need to write a test for each step. These should ideally assert that the XMLRPC requests made are as we expect them to be.
An idea could be to create a mock RPC client object that also satisfies the RPC interface
type RPCMockClient struct {...}
func (c *RPCMockClient) Call(method string, params interface{}, result interface{}) error {...}
This would take a whole bunch of effort.
Hello all,
I'm trying to build a "vdi_vhd" image using packer on xenserver, but i have got the below error, i really don't know which is wrong, could you please anyone help me on this,
Thanks in advance.
[root@localhost bin]# packer build /usr/local/test-scripts/main.json
xenserver-iso output will be in this color.
==> xenserver-iso: XAPI client session established
==> xenserver-iso: Downloading or copying ISO
xenserver-iso: Downloading or copying: http://www.mirrorservice.org/sites/mirror.centos.org/7.6.1810/isos/x86_64/CentOS-7-x86_64-Minimal-1810.iso
xenserver-iso: Error downloading: open : no such file or directory
==> xenserver-iso: ISO download failed. Build 'xenserver-iso' errored: ISO download failed.
==> Some builds didn't complete successfully and had errors:
--> xenserver-iso: ISO download failed.
==> Builds finished but no artifacts were created.
mkdir -p /usr/local/packer/
cd /usr/local/packer/
wget https://releases.hashicorp.com/packer/1.4.1/packer_1.4.1_linux_amd64.zip
unzip packer_1.4.1_linux_amd64.zip
vim ~/.bashrc
##added the below
export PATH=/usr/local/packer/:$PATH
##save and exit
sudo ln -s /usr/local/packer/packer /usr/bin/packer
source ~/.bashrc
RELEASE="go1.12.6.linux-amd64.tar.gz";
cd /tmp && curl -L -O "https://dl.google.com/go/${RELEASE}";
tar -zxvf "${RELEASE}";
mv -v go $HOME/go-1.12.6;
rm -f "/tmp/${RELEASE}";
vim ~/.bashrc
##added the below
export GOROOT=$HOME/go-1.12.6;
export GOPATH=$HOME/go-workspace;
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin;
##save and exit
source ~/.bashrc
mkdir -p $GOPATH/src/github.com/hashicorp/packer;
cd $GOPATH/src/github.com/hashicorp/packer;
go get github.com/mitchellh/gox;
go get github.com/mitchellh/go-vnc;
cd $GOPATH;
PROV="src/github.com/xenserver";
mkdir -p $PROV && cd $PROV;
git clone https://github.com/xenserver/packer-builder-xenserver.git;
cd packer-builder-xenserver;
./build.sh;
[root@localhost bin]# ll
total 34732
-rwxr-xr-x. 1 root root 17813736 Jul 2 12:04 packer-builder-xenserver-iso
-rwxr-xr-x. 1 root root 17747856 Jul 2 12:04 packer-builder-xenserver-xva
[root@localhost bin]# pwd
/root/go-workspace/src/github.com/xenserver/packer-builder-xenserver/bin
[root@localhost bin]#
NOTE: I've installed packer and xenserver plugin on my Virtual-box local server
{
"builders": [
{
"iso_checksum": "38d5d51d9d100fd73df031ffd6bd8b1297ce24660dc8c13a3b8b4534a4bd291c",
"iso_checksum_type": "sha256",
"iso_url": "{{user `mirror`}}/7.6.1810/isos/x86_64/CentOS-7-x86_64-Minimal-1810.iso",
"output_directory": "CentOS-7-x86_64-xenserver-minimal",
"format": "vdi_vhd",
"remote_host": "192.1XX.XX.XX",
"remote_password": "XXXXX",
"remote_username": "root",
"shutdown_command": "/sbin/halt",
"ssh_password": "XXXXX",
"ssh_username": "root",
"ssh_wait_timeout": "10000s",
"type": "xenserver-iso",
"vm_name": "packer-centos-7.6-x86_64"
}
],
"variables": {
"mirror": "http://www.mirrorservice.org/sites/mirror.centos.org"
}
}
Above is the packer code which i used.
I successfully built a development version of packer in $GOPATH, however building packer-builder-xenserver in $GOPATH seems to not work.
[15:26:22 booi@bear:packer-builder-xenserver 127]$ ./build.sh
==> Getting dependencies...
# github.com/rdobson/packer-builder-xenserver/builder/xenserver/common
builder/xenserver/common/common_config.go:57: undefined: packer.ConfigTemplate
builder/xenserver/common/step_type_boot_command.go:27: undefined: packer.ConfigTemplate
==> Removing old directory...
Number of parallel builds: 8
--> darwin/amd64: github.com/rdobson/packer-builder-xenserver/plugin/builder-xenserver-iso
--> darwin/amd64: github.com/rdobson/packer-builder-xenserver/plugin/builder-xenserver-xva
2 errors occurred:
--> darwin/amd64 error: exit status 2
Stderr: # github.com/rdobson/packer-builder-xenserver/builder/xenserver/common
builder/xenserver/common/common_config.go:57: undefined: packer.ConfigTemplate
builder/xenserver/common/step_type_boot_command.go:27: undefined: packer.ConfigTemplate
--> darwin/amd64 error: exit status 2
Stderr: # github.com/rdobson/packer-builder-xenserver/builder/xenserver/common
builder/xenserver/common/common_config.go:57: undefined: packer.ConfigTemplate
builder/xenserver/common/step_type_boot_command.go:27: undefined: packer.ConfigTemplate
I have an old Dell computer that has Citrix XenServer 6.5 and SP1 freshly installed. The packer command fails with the following error.
C:\GO\src\github.com\xenserver\packer-builder-xenserver\examples>packer build -debug centos-6.6-mine.json
Debug mode enabled. Builds will not be parallelized.
xenserver-iso output will be in this color.
==> xenserver-iso: XAPI client session established
==> xenserver-iso: Downloading or copying ISO
xenserver-iso: Downloading or copying: http://archive.kernel.org/centos-vault/6.6/isos/x86_64/CentOS-6.6-x86_64-minimal.
o
==> xenserver-iso: Starting HTTP server on port 8000
==> xenserver-iso: Step: Upload VDI 'CentOS-6.6-x86_64-minimal.iso'
==> xenserver-iso: PUT 'https://192.168.0.17/import_raw_vdi?session_id=OpaqueRef%3Ae2b24d54-c436-58f9-380e-5515178a758f&task
d=OpaqueRef%3A01f2c92a-24de-4318-9562-b8ab92b74c2c&vdi=OpaqueRef%3Aa5a7b22b-bb17-436b-ac2d-1031e94046e8'
==> xenserver-iso: Step: Create Instance
==> xenserver-iso: Created instance '1e6d17ed-2d17-f9a7-bf13-b75709e92422'
==> xenserver-iso: Step: Start VM Paused
==> xenserver-iso: Unable to start VM with UUID '1e6d17ed-2d17-f9a7-bf13-b75709e92422': API Error: [NO_HOSTS_AVAILABLE]
==> xenserver-iso: Destroying VM
==> xenserver-iso: Destroying VDI
==> xenserver-iso: Destroyed VDI 'CentOS-6.6-x86_64-minimal.iso'
==> xenserver-iso: Deleting output directory...
Build 'xenserver-iso' errored: Build was halted.
==> Some builds didn't complete successfully and had errors:
--> xenserver-iso: Build was halted.
==> Builds finished but no artifacts were created.
C:\GO\src\github.com\xenserver\packer-builder-xenserver\examples>
The json file is pretty vanilla. Only changed the hostname/password from the sample json file.
Thanks.
Sits here forever:
systems-samm ~/src/github.com/rdobson/packer-builder-xenserver/examples % packer build centos-6.6.json
xenserver-iso output will be in this color.
==> xenserver-iso: XAPI client session established
==> xenserver-iso: Downloading or copying ISO
xenserver-iso: Downloading or copying: http://centos.mirror.serversaustralia.com.au/6.6/isos/x86_64/CentOS-6.6-x86_64-minimal.iso
==> xenserver-iso: Starting HTTP server on port 8000
==> xenserver-iso: Step: Upload VDI 'CentOS-6.6-x86_64-minimal.iso'
==> xenserver-iso: PUT 'https://s1-dl360-01/import_raw_vdi?session_id=OpaqueRef%3A75b48216-2034-aa42-7a71-f3851fde3cb9&task_id=OpaqueRef%3A3fd254c0-412b-e363-d3fe-d29cb50ab6da&vdi=OpaqueRef%3A864e8a33-a30e-1166-0631-6c09fe328af7'
But I can see the .iso appear in XenCentre:
Right now error reporting is done by calling ui.Error
to print a red message. However, this message can easily get lost amongst the noise of any other builders running simultaneously. This is why other builders also do a state.Put("error", err)
before returning multistep.ActionHalt
-- this way Packer can repeat the error at the end, when all the builders have terminated.
(I avoided doing this at first because it would introduce a huge amount of additional code noise, so if there's a clean way to do this then that would be good.)
I'm going to preface this by saying that I'm using a version built with your pull request for the latest version of packer merged in, so this error might very well be due to that.
==> xenserver-iso: XAPI client session established
==> xenserver-iso: Downloading or copying ISO
xenserver-iso: Downloading or copying: http://www.mirrorservice.org/sites/mirror.centos.org/6.6/isos/x86_64/CentOS-6.6-x86_64-minimal.iso
==> xenserver-iso: Starting HTTP server on port 8000
==> xenserver-iso: Step: Upload VDI 'CentOS-6.6-x86_64-minimal.iso'
==> xenserver-iso: PUT 'https://example.com/import_raw_vdi?session_id=OpaqueRef%3A8c14557d-cdad-547b-e711-a532b85865aa&task_id=OpaqueRef%3Aea957d14-7b25-3a47-6e8f-1b0279e223cf&vdi=OpaqueRef%3Aa41dcfd5-2ed1-428e-0438-05478e71c9b2'
==> xenserver-iso: Step: Create Instance
==> xenserver-iso: Created instance 'a576526a-7f0f-58e8-939e-b1bd8cd519ff'
==> xenserver-iso: Error attaching VDI '36bcc00c-6280-446b-b56d-b4fe2bf11793': 'API Error: [VDI_IS_NOT_ISO OpaqueRef:a41dcfd5-2ed1-428e-0438-05478e71c9b2 user]'
==> xenserver-iso: Destroying VM
==> xenserver-iso: Destroying VDI
==> xenserver-iso: Destroyed VDI 'CentOS-6.6-x86_64-minimal.iso'
==> xenserver-iso: Deleting output directory...
Logging into the box while it's running, I can see it creates the vdi and the vm, so I don't see what the problem is? Seems to possibly creating the vdi as a VHD instead of a cd and then trying to mount it as a CD?. I don't really know anything about go, so it's hard for me to untangle what it's doing in the code.
vdi params for the image that it uploaded:
uuid ( RO) : 36bcc00c-6280-446b-b56d-b4fe2bf11793
name-label ( RW): CentOS-6.6-x86_64-minimal.iso
name-description ( RW):
is-a-snapshot ( RO): false
snapshot-of ( RO):
snapshots ( RO):
snapshot-time ( RO): 19700101T00:00:00Z
allowed-operations (SRO): update; resize; destroy; clone; copy; snapshot
current-operations (SRO):
sr-uuid ( RO): 8e225b79-fab2-8166-4eaf-99d7a9899c02
sr-name-label ( RO): Local storage
vbd-uuids (SRO): d06b3eb8-6581-cda6-59ac-968e7500e19e
crashdump-uuids (SRO):
virtual-size ( RO): 402653184
physical-utilisation ( RO): 411041792
location ( RO): 36bcc00c-6280-446b-b56d-b4fe2bf11793
type ( RO): User
sharable ( RO): false
read-only ( RO): false
storage-lock ( RO): false
managed ( RO): true
parent ( RO):
missing ( RO): false
other-config (MRW): temp: temp
xenstore-data (MRO):
sm-config (MRO): host_OpaqueRef:1ee56f53-0392-1105-e0e4-1a80349152b2: RW; vdi_type: vhd
on-boot ( RW): persist
allow-caching ( RW): false
metadata-latest ( RO): false
metadata-of-pool ( RO):
tags (SRW):
the json config i'm using.
config.json
{
"builders": [
{
"type": "xenserver-iso",
"remote_host": "example.com",
"remote_username": "user",
"remote_password": "password",
"boot_command": [
"<tab> text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/centos6-ks.cfg<enter><wait>"
],
"boot_wait": "10s",
"disk_size": 40960,
"http_directory": "http",
"iso_checksum": "4ed6c56d365bd3ab12cd88b8a480f4a62e7c66d2",
"iso_checksum_type": "sha1",
"iso_url": "{{user `mirror`}}/6.6/isos/x86_64/CentOS-6.6-x86_64-minimal.iso",
"output_directory": "packer-centos-6.6-x86_64-xenserver",
"shutdown_command": "/sbin/halt",
"ssh_username": "root",
"ssh_password": "vmpassword",
"ssh_wait_timeout": "10000s",
"vm_name": "packer-centos-6.6-x86_64",
"vm_description": "Build time: {{isotime}}"
}
],
"variables": {
"mirror": "http://www.mirrorservice.org/sites/mirror.centos.org"
}
}
My understanding is that packer build -on-error=ask
should ask me what to do.
We do have keep_vm
, but it seems like it's ... redundant? IMO we should just let the -on-error=ask let me decide what to do.
These options are nice for debugging.
I have recently:
I need to package up this builder to be used by our release and QA teams and I would much rather put in some effort to get this builder included in the main packer repo than maintain it separately.
Thoughts, objections, etc.?
==> xenserver-xva: Creating a local port forward over SSH on local port 5901
==> xenserver-xva: Port forward setup. 5901 ---> 172.16.170.77:22 on 172.16.170. 16
==> xenserver-xva: Deleting output directory...
Build 'xenserver-xva' errored: unknown communicator type:
==> Some builds didn't complete successfully and had errors:
--> xenserver-xva: unknown communicator type:
==> Builds finished but no artifacts were created.
I've been recently sponsored to work on a terraform provider that integrates with Xenorchestra (and XCP-ng / xenserver). Part of the vision for that work is also strengthening other complementary tools (packer being one of them).
I've started a fork (ddelnano/packer-builder-xenserver) which is now fully functional. It improves upon this project with the following:
Is there any interest in the xenserver team maintaining this project? If not, I would like to take over ownership of it. In order to transfer ownership I'm suggesting the following changes:
If you don't have any issues with what I'm suggesting above, please let me know and I'd be happy to make the PRs myself.
Please add documentation on how to build compressed XVAs.
export USE_XE=1
I've managed to install packer-builder-xenserver
and I'd like to make my first VM on XenServer. However it looks like the packer is failing to setup the VNC connection appropriately. Has any of your encountered this problem before?
Debug mode enabled. Builds will not be parallelized.
xenserver-iso output will be in this color.
==> xenserver-iso: XAPI client session established
==> xenserver-iso: Downloading or copying ISO
xenserver-iso: Downloading or copying: http://ftp.freebsd.org/pub/FreeBSD/releases/amd64/amd64/ISO-IMAGES/10.1/FreeBSD-10.1-RELEASE-amd64-disc1.iso
==> xenserver-iso: Starting HTTP server on port 8000
==> xenserver-iso: Step: Upload VDI 'FreeBSD-10.1-RELEASE-amd64-disc1.iso'
==> xenserver-iso: PUT 'https://MYHOST/import_raw_vdi?session_id=OpaqueRef%3A82c1fe80-446f-b816-63ba-f4fa70373341&task_id=OpaqueRef%3A16b53b84-fdde-273a-b412-f6d1608bb894&vdi=OpaqueRef%3Aa4ebd59a-9718-6c1b-3de6-d9d12da1faae'
==> xenserver-iso: Step: Create Instance
==> xenserver-iso: Created instance '35efa0ab-964e-f24b-225b-47cc5617aec6'
==> xenserver-iso: Step: Start VM Paused
==> xenserver-iso: Step: Set SSH address to VM host IP
==> xenserver-iso: Set host SSH address to 'MYIPADDRESS'.
==> xenserver-iso: Step: forward the instances VNC port over SSH
==> xenserver-iso: Unable to get VNC port (is the VM running?): ssh: handshake failed: ssh: unable to authenticate, attempted methods [none], no supported methods remain
==> xenserver-iso: Destroying VM
==> xenserver-iso: Destroying VDI
==> xenserver-iso: Destroyed VDI 'FreeBSD-10.1-RELEASE-amd64-disc1.iso'
==> xenserver-iso: Deleting output directory...
Build 'xenserver-iso' errored: Build was halted.
==> Some builds didn't complete successfully and had errors:
--> xenserver-iso: Build was halted.
==> Builds finished but no artifacts were created.
This is a workaround for the Windows BSOD, when that's fixed we probably want to move the "device detach" steps back to where it was, between step_shutdown
and step_export
. This lets us get rid of a whole shutdown-restart cycle.
Hi,
I tried to create an Debian Stretch Config based upon the provided Centos Example, but no matter what I try packer doesn't seem to recognize the shutdown command.
I tried
/bin/sysctl poweroff
/sbin/shutdown -h now
/sbin/shutdown -P now
/sbin/halt
it doesn't make a difference. Except for /bin/sysctl poweroff which reduces the Log by following error
==> xenserver-iso: Unable to detach VDI 'ae55962b-0e2e-42c2-af3f-7f0cbde8803d': Could not find VBD for VDI 'OpaqueRef:cdb8d3c5-f016-6930-e953-e57eade7dd12'
which I guess is caused by already unmounting the iso when brought down with the other commands.
Log
xenserver-iso output will be in this color.
==> xenserver-iso: XAPI client session established
==> xenserver-iso: Downloading or copying ISO
xenserver-iso: Downloading or copying: http://localhost/iso/debian-9.1.0-amd64-netinst.iso
==> xenserver-iso: Starting HTTP server on port 8000
==> xenserver-iso: Step: Upload VDI 'debian-9.1.0-amd64-netinst.iso'
==> xenserver-iso: PUT 'https://xe.local/import_raw_vdi?session_id=OpaqueRef%3Ad977d153-07b5-faee-beb0-235bf2dfe52e&task_id=OpaqueRef%3Abc4666ba-c8dd-41bd-0b3a-0eae3439f8b4&vdi=OpaqueRef%3Acdb8d3c5-f016-6930-e953-e57eade7dd12'
==> xenserver-iso: Step: Create Instance
==> xenserver-iso: Created instance 'e3a41b4d-972a-cd93-090b-6803c23c5dbb'
==> xenserver-iso: Step: Start VM Paused
==> xenserver-iso: Step: Set SSH address to VM host IP
==> xenserver-iso: Set host SSH address to '10.0.0.3'.
==> xenserver-iso: Step: forward the instances VNC port over SSH
==> xenserver-iso: Creating a local port forward over SSH on local port 5900
==> xenserver-iso: Port forward setup. 5900 ---> 127.0.0.1:5908 on 10.0.0.3
==> xenserver-iso: Unpausing VM e3a41b4d-972a-cd93-090b-6803c23c5dbb
==> xenserver-iso: Waiting 10s for boot...
==> xenserver-iso: Connecting to the VM over VNC
xenserver-iso: Using local port: 5900
xenserver-iso: Found local IP: 172.16.0.99
==> xenserver-iso: Typing boot commands over VNC...
==> xenserver-iso: Finished typing.
==> xenserver-iso: Step: Wait for VM's IP to become known to us.
xenserver-iso: Got IP '192.168.88.254' from HTTP request
==> xenserver-iso: Got IP address '192.168.88.254'
==> xenserver-iso: Not using SSH port forwarding
==> xenserver-iso: Waiting for SSH to become available...
==> xenserver-iso: Connected to SSH!
==> xenserver-iso: Step: Shutting down VM
xenserver-iso: Executing shutdown command...
==> xenserver-iso: Shutdown command failed: wait: remote command exited without exit status or exit signal
==> xenserver-iso: WARNING: Forcing hard shutdown of the VM...
xenserver-iso: Successfully shut down VM
==> xenserver-iso: Unable to detach VDI 'ae55962b-0e2e-42c2-af3f-7f0cbde8803d': Could not find VBD for VDI 'OpaqueRef:cdb8d3c5-f016-6930-e953-e57eade7dd12'
==> xenserver-iso: Step: export artifact
==> xenserver-iso: Getting XVA https://xe.local/export?uuid=e3a41b4d-972a-cd93-090b-6803c23c5dbb&session_id=OpaqueRef:d977d153-07b5-faee-beb0-235bf2dfe52e
==> xenserver-iso: Download completed: packer-debian-9-x86_64-xenserver
==> xenserver-iso: Destroying VM
==> xenserver-iso: Destroying VDI
==> xenserver-iso: Destroyed VDI 'debian-9.1.0-amd64-netinst.iso'
Build 'xenserver-iso' finished.
==> Builds finished. The artifacts of successful builds are:
--> xenserver-iso: VM files in directory: packer-debian-9-x86_64-xenserver
Config
{
"builders": [
{
"type": "xenserver-iso",
"remote_host": "xe.local",
"remote_username": "root",
"remote_password": "xAjX0MgPi1zWbZyGKtFG",
"boot_command": [
"<esc> auto url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/debian9-ks.cfg <enter><wait>"
],
"boot_wait": "10s",
"disk_size": 10000,
"http_directory": "http",
"iso_checksum": "151c200204d2930aa74e92c9884d7b613296e7bf",
"iso_checksum_type": "sha1",
"iso_url": "http://localhost/iso/debian-9.1.0-amd64-netinst.iso",
"vm_other_config": {
"conversionvm":"true"
},
"network_names": [
"ext_bond"
],
"output_directory": "packer-debian-9-x86_64-xenserver",
"shutdown_command": "/bin/systemctl poweroff",
"ssh_username": "root",
"ssh_password": "vmpassword",
"ssh_wait_timeout": "10000s",
"ssh_no_proxy": true,
"expect_disconnect": true,
"shutdown_timeout": "3m",
"install_timeout": "30m",
"vm_name": "packer-debian-9-x86_64",
"vm_description": "Build time: {{isotime}}",
"vm_memory": 512,
"tools_iso_name": "guest-tools.iso"
}
],
}
Preseed File
d-i debian-installer/locale string de_DE.UTF-8
d-i keyboard-configuration/xkb-keymap select de
d-i keyboard-configuration/toggle select No toggling
d-i netcfg/choose_interface select auto
d-i netcfg/dhcp_timeout string 60
d-i netcfg/get_hostname string unassigned-hostname
d-i netcfg/get_domain string unassigned-domain
d-i netcfg/wireless_wep string
d-i hw-detect/load_firmware boolean true
d-i mirror/country string manual
d-i mirror/http/hostname string ftp.de.debian.org
d-i mirror/http/directory string /debian
d-i mirror/http/proxy string
d-i passwd/root-password password vmpassword
d-i passwd/root-password-again password vmpassword
d-i passwd/user-fullname string vh
d-i passwd/username string vh
d-i passwd/user-password password vmpassword
d-i passwd/user-password-again password vmpassword
d-i clock-setup/utc boolean true
d-i time/zone string Europe/Berlin
d-i clock-setup/ntp boolean true
d-i partman-auto/method string lvm
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-md/device_remove_md boolean true
d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm_nooverwrite boolean true
d-i partman-auto/choose_recipe select atomic
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
d-i partman-md/confirm boolean true
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
d-i apt-setup/non-free boolean true
d-i apt-setup/contrib boolean true
tasksel tasksel/first multiselect standard, ssh-server
d-i grub-installer/only_debian boolean true
d-i grub-installer/with_other_os boolean true
d-i grub-installer/bootdev string default
d-i finish-install/reboot_in_progress note
d-i preseed/late_command string \
sed -i 's/#PermitRootLogin.*/PermitRootLogin yes/g' /target/etc/ssh/sshd_config
user variables used inside boot_command are not detected.
For eg:
"boot_command": [
" text ",
" text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/centos7-ks.cfg ",
"{{user boot_args
}}"
],
Even when "boot_args" are defined as user variable, it results to empty.
It might be instructive to look at (read: copy) the preexisting documentation for other builders:
https://github.com/mitchellh/packer/tree/master/website/source/docs/builders
Most things could be copied from the xenserver-iso
documentation, but be careful to remove the iso-builder-specific config keys.
Reference files:
For those who have instant timeouts for WinRM, the default is not the expected 20 minutes (like for SSH timeout).
You need to set "winrm_timeout": "10000s"
in the config.
I am currently experimenting with the 6.x-support branch. I've been able to create an Ubuntu 12.04 image (based on https://github.com/xenserver/packer-templates/blob/master/ubuntu-12.04-amd64.json) and now I am trying to add PV support.
Installing the guest utilities and linux-virtual is done in a provision script but I am unsure about setting VM parameters such as PV-bootloader and PV-args, and marking the first disk as bootable. Is that really supposed to happen in a provision script executed on the VM itself or are there any xenserver-iso configuration parameters I have missed?
The ISO builder is able to communicate with new vms over ssh with a config like the following:
"ssh_username": "root",
"ssh_password": "{{ user `vm_root_password` }}",
"ssh_wait_timeout": "300s",
With the XVA builder, the same config will produce an error unknown communicator type
. Setting "communicator": "ssh"
, fixes the issue. Unfortunately, the ssh timeout is then 0 seconds, which causes builds to fail with Timeout waiting for SSH.
That can be fixed by setting ssh_timeout
to a non-zero value:
"communicator": "ssh",
"ssh_username": "root",
"ssh_password": "{{ user `vm_root_password` }}",
"ssh_timeout": "300s"
Would be nice if the behavior was consistent, suspect this line needs to be added to the xva builder: https://github.com/xenserver/packer-builder-xenserver/blob/5e1f8571d678e47779a1cfed03794142d32a3b66/builder/xenserver/iso/builder.go#L70
Hi, there is a way to set up the name of disk created by packer. So far the disk is named "Packer-disk", I would like to change it.
Thanks
Hi Team
I am trying to use this plugin to make Xen VMs , when I try to issue command "packer build xx.json" , its says incompatible API version , please help . My packer version is at "1.5.6"
Please help me with the solution
Hy,
I am trying to install the plugin on one of our systems, but I am missing something.
When running the build:
./bin/packer build --only=edge-xenserver -debug -on-error=ask /tmp/packer.json
Failed to initialize build 'edge-xenserver': error initializing builder 'xenserver-iso': plugin exited before we could connect
Debug mode enabled. Builds will not be parallelized.
edge-xenserver output will be in this color.
==> Builds finished but no artifacts were created.
I cannot get any further information or error on what the issue is :(
After building from source I see the files there:
bash-4.3# ls -l bin/
total 88808
-rwxr-xr-x 1 root root 3175268 Aug 2 12:15 gox
-rwxr-xr-x 1 root root 54773371 Aug 2 12:16 packer
-rwxr-xr-x 1 root root 16530287 Aug 2 12:16 packer-builder-xenserver-iso
-rwxr-xr-x 1 root root 16453197 Aug 2 12:16 packer-builder-xenserver-xva
bash-4.3# ./bin/packer-builder-xenserver-iso
panic: Please do not execute plugins directly. Packer will execute these for you.
goroutine 1 [running]:
main.main()
/go/src/github.com/xenserver/packer-builder-xenserver/plugin/builder-xenserver-iso/main.go:11 +0x9e
The config is very basic:
{
"name": "xenserver",
"type": "xenserver-iso",
"iso_url": "/tmp/cd.iso",
"iso_checksum": "769474248a3897f4865817446f9a4a53",
"iso_checksum_type": "md5",
"ssh_username": "{{user `user_name`}}",
"ssh_password": "{{user `user_password`}}",
"ssh_timeout": "15m",
"remote_host": "xen.example.com",
"remote_username": "root",
"remote_password": "root",
"vm_name": "xen-latest",
"output_directory": "output",
"format": "vdi",
"vm_memory": "2049",
"floppy_files": [
"preseed-xen.cfg"
],
"disk_size": 8000,
"boot_wait": "15s",
"boot_command": [
"<enter><wait>",
"<f6><esc>",
"<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
"<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
"<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
"<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
"<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
"<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
"<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
"<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
"<bs><bs><bs>",
"/install/vmlinuz ",
"auto=true priority=critical ",
"preseed/file=/floppy/preseed-virtualbox.cfg ",
"net.ifnames=0 biosdevname=0 ",
"netcfg/get_hostname=xen ",
"netcfg/get_domain=xen ",
"initrd=/install/initrd.gz -- <enter>"
]
},
Some values are bogus, just showing what values are. I tried with adding bogus remote_host, or invalid user/pass, but error does not change. When logging into xenserver the values are correct.
Thank you for any help
I'm on Ubuntu 14.04 and I had to make this change for it to work -
$ git diff
diff --git a/build.sh b/build.sh
index 4fdbcc3..eebefa2 100755
--- a/build.sh
+++ b/build.sh
@@ -32,7 +32,7 @@ case $(uname) in
;;
esac
OLDIFS=$IFS
-IFS=: MAIN_GOPATH=($GOPATH)
+IFS=: MAIN_GOPATH=$GOPATH
IFS=$OLDIFS
# Copy our OS/Arch to the bin/ directory
diff --git a/builder/xenserver/common/step_start_on_himn.go b/builder/xenserver/common/step_start_on_himn.go
index 50b5aee..e39c154 100644
--- a/builder/xenserver/common/step_start_on_himn.go
+++ b/builder/xenserver/common/step_start_on_himn.go
@@ -1,7 +1,7 @@
package common
import (
- gossh "code.google.com/p/go.crypto/ssh"
+ gossh "golang.org/x/crypto/ssh"
"fmt"
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
The idea is to add an "other-config" key to our uploaded VDIs, set to the checksum that Packer internally names the ISOs as it caches them locally.
We need to figure out how/when to clear out the cache to stop it filling up. As the caching is transparent to the user, it will be unexpected behaviour if an SR fills up due to the caching.
step_start_on_himn
still exists, even though we no longer use that step to specifically start the VM on the HIMN. However, we do want the IP detection code that is in that file. Look at moving that code into step_wait_for_ip
.
We have a slightly quirky network setup, where vms are not typically in the same network as our Xen servers. This means that it is impossible to ssh into a new vm from a Xen server dom0.
Would you be open to adding a config flag to skip setting up port forwarding during the ssh step and instead contact the guest directly? If so, I will take a whack at a PR (no Go experience, unfortunately, so it may be a while)
Was (XenServer 6.5): xs-tools.iso
Is (for XenServer 7): guest-tools.iso
There is a problem with StepGetVNCPort, when you try to use this plugin on a xen pool.
The problem is that you try to retrieve vnc port through the xenstore using ssh, but on a pool the vm could be created on a different xenserver than one used for the initial connection, and the xenstore is local to one xenserver not to a pool, so packer failed.
Maybe a solution should be to use the API instead of using xenstore through ssh, or maybe iterate over all members of the xen pool to find where the vm was created.
127.0.0.1
rather than the IP gotten from XenServer tools.winrm_port
is given in the config, it is ignored.I've made a hackish patch for this @ https://github.com/dongyuzheng/packer-builder-xenserver/tree/winrm_fix
network_name
is currently common to both builders (in common_config.go
as it should be), but xenserver-xva
does not respect it, as the code in question is currently commented out in xva/step_import_instance.go
(as it has not been tested).vm_memory
is duplicated in the code of the XVA builder and the ISO builder (in xva/config.go
and iso/config.go
respectively). We want to merge those two into the common config, like network_name
currently is. In addition, the code for actually setting the VM memory is also commented out in the XVA builder.We should check whether the strings specified in floppy_files
refer to actual files/directories, and whether http_directory
exists, so that we can report an error before doing anything.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.