ddelnano / packer-plugin-xenserver

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

Fix winrm support in the packer builder #6

Open ddelnano opened 3 years ago

ddelnano commented 3 years ago

As discussed here, the packer builder does not work with winrm. This issue will be used to track fixing this feature.

fanuelsen commented 3 years ago

The xenserver-iso builder starts the VM boots the image and loads autounattened.xml and the scripts. Then when its about to connect to winrm it fails in aloop as you can see from the log output under. i'm not sure what happens but it looks like its trying to run winrm over ssh?

Packer json file { "builders": [ { "type": "xenserver-iso", "sr_name": "SRNAME", "sr_iso_name": "ISOREP", "remote_host": "192.168.1.20, "remote_username": "root", "remote_password": "password", "tools_iso_name": "XCP-ng.Windows.PV.Drivers.8.2.2.200-rc1.iso", "vm_name": "packer-win2012", "vcpus_max": "4", "vm_memory": "4096", "communicator": "winrm", "host_port_min": "5985", "host_post_max": "5985", "winrm_insecure": true, "winrm_port": 5985, "winrm_use_ntlm": true, "keep_vm": "always", "disk_size": 61440, "iso_url": "w2012.iso", "iso_checksum_type": "sha256", "iso_checksum": "6612b5b1f53e845aacdf96e974bb119a3d9b4dcb5b82e65804ab7e534dc7b4d5", "http_directory": "http", "ssh_username": "administrator", "ssh_password": "packer", "winrm_username": "administrator", "winrm_password": "packer", "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"", "floppy_files": [ "answer_files/2012/gui/autounattend.xml", "scripts/install-xcpng-tools.ps1", "scripts/set-cert-thumbprint.ps1" ], "boot_wait": "10s" } ] }

Packer log output 2021/01/13 08:39:10 [INFO] Packer version: 0.10.2 2021/01/13 08:39:10 Packer Target OS/Arch: linux amd64 2021/01/13 08:39:10 Built with Go Version: go1.7.1 2021/01/13 08:39:10 [DEBUG] Discovered plugin: xenserver_0 = /home/fanuelsen/packertest/packer-builder-xenserver_0.1.1_linux_amd64.zip 2021/01/13 08:39:10 [DEBUG] Discovered plugin: xenserver_v0 = /home/fanuelsen/packertest/packer-builder-xenserver_v0.1.1 2021/01/13 08:39:10 Detected home directory from env var: /home/fanuelsen 2021/01/13 08:39:10 [DEBUG] Discovered plugin: xenserver-iso = /home/fanuelsen/.packer.d/plugins/packer-builder-xenserver-iso 2021/01/13 08:39:10 [DEBUG] Discovered plugin: xenserver_0 = /home/fanuelsen/.packer.d/plugins/packer-builder-xenserver_0.1.1_linux_amd64.zip 2021/01/13 08:39:10 [DEBUG] Discovered plugin: xenserver_0 = /home/fanuelsen/packertest/packer-builder-xenserver_0.1.1_linux_amd64.zip 2021/01/13 08:39:10 [DEBUG] Discovered plugin: xenserver_v0 = /home/fanuelsen/packertest/packer-builder-xenserver_v0.1.1 2021/01/13 08:39:10 Using internal plugin for qemu 2021/01/13 08:39:10 Using internal plugin for vmware-vmx 2021/01/13 08:39:10 Using internal plugin for null 2021/01/13 08:39:10 Using internal plugin for digitalocean 2021/01/13 08:39:10 Using internal plugin for docker 2021/01/13 08:39:10 Using internal plugin for file 2021/01/13 08:39:10 Using internal plugin for googlecompute 2021/01/13 08:39:10 Using internal plugin for openstack 2021/01/13 08:39:10 Using internal plugin for parallels-iso 2021/01/13 08:39:10 Using internal plugin for virtualbox-ovf 2021/01/13 08:39:10 Using internal plugin for amazon-chroot 2021/01/13 08:39:10 Using internal plugin for parallels-pvm 2021/01/13 08:39:10 Using internal plugin for virtualbox-iso 2021/01/13 08:39:10 Using internal plugin for vmware-iso 2021/01/13 08:39:10 Using internal plugin for amazon-instance 2021/01/13 08:39:10 Using internal plugin for azure-arm 2021/01/13 08:39:10 Using internal plugin for amazon-ebs 2021/01/13 08:39:10 Using internal plugin for ansible 2021/01/13 08:39:10 Using internal plugin for chef-solo 2021/01/13 08:39:10 Using internal plugin for puppet-masterless 2021/01/13 08:39:10 Using internal plugin for shell 2021/01/13 08:39:10 Using internal plugin for shell-local 2021/01/13 08:39:10 Using internal plugin for windows-restart 2021/01/13 08:39:10 Using internal plugin for ansible-local 2021/01/13 08:39:10 Using internal plugin for chef-client 2021/01/13 08:39:10 Using internal plugin for file 2021/01/13 08:39:10 Using internal plugin for powershell 2021/01/13 08:39:10 Using internal plugin for puppet-server 2021/01/13 08:39:10 Using internal plugin for salt-masterless 2021/01/13 08:39:10 Using internal plugin for windows-shell 2021/01/13 08:39:10 Using internal plugin for amazon-import 2021/01/13 08:39:10 Using internal plugin for vagrant 2021/01/13 08:39:10 Using internal plugin for vsphere 2021/01/13 08:39:10 Using internal plugin for docker-tag 2021/01/13 08:39:10 Using internal plugin for shell-local 2021/01/13 08:39:10 Using internal plugin for artifice 2021/01/13 08:39:10 Using internal plugin for atlas 2021/01/13 08:39:10 Using internal plugin for compress 2021/01/13 08:39:10 Using internal plugin for docker-import 2021/01/13 08:39:10 Using internal plugin for docker-push 2021/01/13 08:39:10 Using internal plugin for docker-save 2021/01/13 08:39:10 Using internal plugin for vagrant-cloud 2021/01/13 08:39:10 Detected home directory from env var: /home/fanuelsen 2021/01/13 08:39:10 Attempting to open config file: /home/fanuelsen/.packerconfig 2021/01/13 08:39:10 [WARN] Config file doesn't exist: /home/fanuelsen/.packerconfig 2021/01/13 08:39:10 Packer config: &{DisableCheckpoint:false DisableCheckpointSignature:false PluginMinPort:10000 PluginMaxPort:25000 Builders:map[qemu:/home/fanuelsen/packertest/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-qemu >2021/01/13 08:39:10 Setting cache directory: /home/fanuelsen/packertest/packer_cache 2021/01/13 08:39:10 Loading builder: xenserver-iso 2021/01/13 08:39:10 Creating plugin client for path: /home/fanuelsen/.packer.d/plugins/packer-builder-xenserver-iso 2021/01/13 08:39:10 Starting plugin: /home/fanuelsen/.packer.d/plugins/packer-builder-xenserver-iso []string{"/home/fanuelsen/.packer.d/plugins/packer-builder-xenserver-iso"} 2021/01/13 08:39:10 Detected home directory from env var: /home/fanuelsen 2021/01/13 08:39:10 Waiting for RPC address for: /home/fanuelsen/.packer.d/plugins/packer-builder-xenserver-iso 2021/01/13 08:39:10 packer-builder-xenserver-iso: 2021/01/13 08:39:10 Plugin minimum port: 10000 2021/01/13 08:39:10 packer-builder-xenserver-iso: 2021/01/13 08:39:10 Plugin maximum port: 25000 2021/01/13 08:39:10 packer-builder-xenserver-iso: 2021/01/13 08:39:10 Plugin address: unix /tmp/packer-plugin279886691 2021/01/13 08:39:10 packer-builder-xenserver-iso: 2021/01/13 08:39:10 Waiting for connection... 2021/01/13 08:39:10 packer-builder-xenserver-iso: 2021/01/13 08:39:10 Serving a plugin connection... 2021/01/13 08:39:10 ui: ^[[1;32mxenserver-iso output will be in this color.^[[0m 2021/01/13 08:39:10 ui: 2021/01/13 08:39:10 Build debug mode: false 2021/01/13 08:39:10 Force build: false 2021/01/13 08:39:10 Preparing build: xenserver-iso 2021/01/13 08:39:10 Waiting on builds to complete... 2021/01/13 08:39:10 Starting build run: xenserver-iso 2021/01/13 08:39:10 Running builder: xenserver-iso 2021/01/13 08:39:10 ui: ^[[1;32m==> xenserver-iso: XAPI client session established^[[0m 2021/01/13 08:39:10 ui: ^[[1;32m==> xenserver-iso: Downloading or copying ISO^[[0m 2021/01/13 08:39:10 ui: ^[[0;32m xenserver-iso: Downloading or copying: file:///home/fanuelsen/packertest/w2012.iso^[[0m 2021/01/13 08:39:10 packer-builder-xenserver-iso: 2021/01/13 08:39:10 Acquiring lock to download: file:///home/fanuelsen/packertest/w2012.iso 2021/01/13 08:39:10 packer-builder-xenserver-iso: 2021/01/13 08:39:10 Parsed URL: &url.URL{Scheme:"file", Opaque:"", User:(*url.Userinfo)(nil), Host:"", Path:"/home/fanuelsen/packertest/w2012.iso", RawPath:"", ForceQuery:false, RawQuery:>2021/01/13 08:39:10 packer-builder-xenserver-iso: 2021/01/13 08:39:10 [DEBUG] Using local file: /home/fanuelsen/packertest/w2012.iso 2021/01/13 08:39:10 packer-builder-xenserver-iso: 2021/01/13 08:39:10 Verifying checksum of /home/fanuelsen/packertest/w2012.iso 2021/01/13 08:39:25 ui: ^[[1;32m==> xenserver-iso: Creating floppy disk...^[[0m 2021/01/13 08:39:25 packer-builder-xenserver-iso: 2021/01/13 08:39:25 Floppy path: /tmp/packer845177190 2021/01/13 08:39:25 packer-builder-xenserver-iso: 2021/01/13 08:39:25 Initializing block device backed by temporary file 2021/01/13 08:39:25 packer-builder-xenserver-iso: 2021/01/13 08:39:25 Formatting the block device with a FAT filesystem... 2021/01/13 08:39:25 packer-builder-xenserver-iso: 2021/01/13 08:39:25 Initializing FAT filesystem on block device 2021/01/13 08:39:25 packer-builder-xenserver-iso: 2021/01/13 08:39:25 Reading the root directory from the filesystem 2021/01/13 08:39:25 ui: ^[[0;32m xenserver-iso: Copying: answer_files/2012/gui/autounattend.xml^[[0m 2021/01/13 08:39:25 packer-builder-xenserver-iso: 2021/01/13 08:39:25 Adding file to floppy: answer_files/2012/gui/autounattend.xml 2021/01/13 08:39:25 ui: ^[[0;32m xenserver-iso: Copying: scripts/install-xcpng-tools.ps1^[[0m 2021/01/13 08:39:25 packer-builder-xenserver-iso: 2021/01/13 08:39:25 Adding file to floppy: scripts/install-xcpng-tools.ps1 2021/01/13 08:39:25 ui: ^[[0;32m xenserver-iso: Copying: scripts/set-cert-thumbprint.ps1^[[0m 2021/01/13 08:39:25 packer-builder-xenserver-iso: 2021/01/13 08:39:25 Adding file to floppy: scripts/set-cert-thumbprint.ps1 2021/01/13 08:39:25 packer-builder-xenserver-iso: 2021/01/13 08:39:25 Looking for an available port between 8000 and 9000 2021/01/13 08:39:25 packer-builder-xenserver-iso: 2021/01/13 08:39:25 Trying port: 8000 2021/01/13 08:39:25 packer-builder-xenserver-iso: 2021/01/13 08:39:25 Port 8000 unavailable: listen tcp :8000: bind: address already in use 2021/01/13 08:39:25 packer-builder-xenserver-iso: 2021/01/13 08:39:25 Trying port: 8001 2021/01/13 08:39:25 ui: ^[[1;32m==> xenserver-iso: Starting HTTP server on port 8001^[[0m 2021/01/13 08:39:25 ui: ^[[1;32m==> xenserver-iso: Step: Upload VDI 'Packer-floppy-disk'^[[0m 2021/01/13 08:39:25 ui: ^[[1;32m==> xenserver-iso: Step: Found SRs '[OpaqueRef:ff20e03e-4526-4822-a8d9-6767223dd729 OpaqueRef:fa097ff3-caa9-48b3-9ef6-c1356bb6dfcc OpaqueRef:f7a727ff-6494-48ed-a93e-ec341e226c95 OpaqueRef:f1681fad-2648-42f>2021/01/13 08:39:25 ui: ^[[1;32m==> xenserver-iso: PUT 'https://192.168.1.20/import_raw_vdi?session_id=OpaqueRef%3A719fea25-ecd3-4b03-a503-0de30c8f25e7&task_id=OpaqueRef%3A5fb0c632-0324-44f5-b0dc-9d29fc3bb5cf&vdi=OpaqueRef%3A4199cc7a-3b97>2021/01/13 08:39:29 packer-builder-xenserver-iso: 2021/01/13 08:39:29 Upload complete 2021/01/13 08:39:29 ui: ^[[1;32m==> xenserver-iso: Step: Upload VDI 'w2012.iso'^[[0m 2021/01/13 08:39:29 ui: ^[[1;32m==> xenserver-iso: Step: Found SRs '[OpaqueRef:ff20e03e-4526-4822-a8d9-6767223dd729 OpaqueRef:fa097ff3-caa9-48b3-9ef6-c1356bb6dfcc OpaqueRef:f7a727ff-6494-48ed-a93e-ec341e226c95 OpaqueRef:f1681fad-2648-42f>2021/01/13 08:39:30 ui: ^[[1;32m==> xenserver-iso: PUT 'https://192.168.1.20/import_raw_vdi?session_id=OpaqueRef%3A719fea25-ecd3-4b03-a503-0de30c8f25e7&task_id=OpaqueRef%3Aa88bf3fe-7e57-4f1d-bc61-10876cd62c9d&vdi=OpaqueRef%3A61f92125-d99d>2021/01/13 08:39:35 packer-builder-xenserver-iso: 2021/01/13 08:39:35 Upload 4% complete 2021/01/13 08:39:40 packer-builder-xenserver-iso: 2021/01/13 08:39:40 Upload 11% complete 2021/01/13 08:39:45 packer-builder-xenserver-iso: 2021/01/13 08:39:45 Upload 18% complete 2021/01/13 08:39:50 packer-builder-xenserver-iso: 2021/01/13 08:39:50 Upload 24% complete 2021/01/13 08:39:55 packer-builder-xenserver-iso: 2021/01/13 08:39:55 Upload 30% complete 2021/01/13 08:40:00 packer-builder-xenserver-iso: 2021/01/13 08:40:00 Upload 37% complete 2021/01/13 08:40:05 packer-builder-xenserver-iso: 2021/01/13 08:40:05 Upload 43% complete 2021/01/13 08:40:10 packer-builder-xenserver-iso: 2021/01/13 08:40:10 Upload 49% complete 2021/01/13 08:40:15 packer-builder-xenserver-iso: 2021/01/13 08:40:15 Upload 55% complete 2021/01/13 08:40:20 packer-builder-xenserver-iso: 2021/01/13 08:40:20 Upload 62% complete 2021/01/13 08:40:25 packer-builder-xenserver-iso: 2021/01/13 08:40:25 Upload 68% complete 2021/01/13 08:40:31 packer-builder-xenserver-iso: 2021/01/13 08:40:31 Upload 75% complete 2021/01/13 08:40:36 packer-builder-xenserver-iso: 2021/01/13 08:40:36 Upload 82% complete 2021/01/13 08:40:41 packer-builder-xenserver-iso: 2021/01/13 08:40:41 Upload 88% complete 2021/01/13 08:40:46 packer-builder-xenserver-iso: 2021/01/13 08:40:46 Upload 94% complete 2021/01/13 08:40:51 packer-builder-xenserver-iso: 2021/01/13 08:40:51 Upload 100% complete 2021/01/13 08:40:52 packer-builder-xenserver-iso: 2021/01/13 08:40:52 Upload complete 2021/01/13 08:40:52 ui: ^[[1;32m==> xenserver-iso: Step: Create Instance^[[0m 2021/01/13 08:40:53 ui: ^[[1;32m==> xenserver-iso: Using the following SR for the VM: OpaqueRef:af81516b-f882-4eb2-b70d-b0309c70af1a^[[0m 2021/01/13 08:40:53 packer-builder-xenserver-iso: 2021/01/13 08:40:53 No network name given, attempting to use management interface 2021/01/13 08:40:53 packer-builder-xenserver-iso: 2021/01/13 08:40:53 Creating VIF on network 'OpaqueRef:ed3b6eb3-9097-4f91-8cb3-5fd85cc6fa29' on VM 'OpaqueRef:f8f6c052-e9d5-4544-9f8e-fe12c10c30f1' 2021/01/13 08:40:53 packer-builder-xenserver-iso: 2021/01/13 08:40:53 Created the following VIF: OpaqueRef:21361bd2-83de-4233-b322-5d9aad178626 2021/01/13 08:40:53 ui: ^[[1;32m==> xenserver-iso: Created instance '80379148-4e4c-3c11-6b39-6f53bd649dd2'^[[0m 2021/01/13 08:40:53 packer-builder-xenserver-iso: 2021/01/13 08:40:53 Running attach vdi for key floppy_vdi_uuid 2021/01/13 08:40:53 packer-builder-xenserver-iso: 2021/01/13 08:40:53 Attached VDI '5f054b42-aa3e-4c5e-b1d2-be495b079075' 2021/01/13 08:40:53 packer-builder-xenserver-iso: 2021/01/13 08:40:53 Running attach vdi for key iso_vdi_uuid 2021/01/13 08:40:54 packer-builder-xenserver-iso: 2021/01/13 08:40:54 Attached VDI '89cae6cd-e04c-453f-81b3-ad1946e1fe75' 2021/01/13 08:40:54 packer-builder-xenserver-iso: 2021/01/13 08:40:54 Running attach vdi for key isoname_vdi_uuid 2021/01/13 08:40:54 packer-builder-xenserver-iso: 2021/01/13 08:40:54 Skipping attach of 'isoname_vdi_uuid' 2021/01/13 08:40:54 packer-builder-xenserver-iso: 2021/01/13 08:40:54 Running attach vdi for key tools_vdi_uuid 2021/01/13 08:40:54 packer-builder-xenserver-iso: 2021/01/13 08:40:54 Attached VDI '9b739a70-d52f-45ad-9819-b89ad9499d25' 2021/01/13 08:40:54 ui: ^[[1;32m==> xenserver-iso: Step: Start VM Paused^[[0m 2021/01/13 08:41:00 ui: ^[[1;32m==> xenserver-iso: Step: Set SSH address to VM host IP^[[0m 2021/01/13 08:41:00 ui: ^[[1;32m==> xenserver-iso: Set host SSH address to '192.168.1.21'.^[[0m 2021/01/13 08:41:00 ui: ^[[1;32m==> xenserver-iso: Unpausing VM 80379148-4e4c-3c11-6b39-6f53bd649dd2^[[0m 2021/01/13 08:41:01 ui: ^[[1;32m==> xenserver-iso: Waiting 10s for boot...^[[0m 2021/01/13 08:41:11 ui: ^[[1;32m==> xenserver-iso: Step: Wait for VM's IP to become known to us.^[[0m 2021/01/13 08:54:56 ui: ^[[0;32m xenserver-iso: Got IP '192.168.1.22' from XenServer tools^[[0m 2021/01/13 08:54:56 ui: ^[[1;32m==> xenserver-iso: Got IP address ''^[[0m 2021/01/13 08:54:56 packer-builder-xenserver-iso: 2021/01/13 08:54:56 Looking for an available port between 5985 and 6000 2021/01/13 08:54:56 packer-builder-xenserver-iso: 2021/01/13 08:54:56 Trying port: 5985 2021/01/13 08:54:56 ui: ^[[1;32m==> xenserver-iso: Creating a local port forward over SSH on local port 5985^[[0m 2021/01/13 08:54:56 ui: ^[[1;32m==> xenserver-iso: Port forward setup. 5985 ---> :22 on 192.168.1.21^[[0m 2021/01/13 08:54:56 packer-builder-xenserver-iso: 2021/01/13 08:54:56 Waiting for WinRM, up to timeout: 30m0s 2021/01/13 08:54:56 ui: ^[[1;32m==> xenserver-iso: Waiting for WinRM to become available...^[[0m 2021/01/13 08:55:01 packer-builder-xenserver-iso: 2021/01/13 08:55:01 [INFO] Attempting WinRM connection... 2021/01/13 08:55:01 packer-builder-xenserver-iso: 2021/01/13 08:55:01 [DEBUG] connecting to remote shell using WinRM 2021/01/13 08:55:01 packer-builder-xenserver-iso: 2021/01/13 08:55:01 ssh.Dial error: ssh: rejected: administratively prohibited (open failed) 2021/01/13 08:55:01 packer-builder-xenserver-iso: 2021/01/13 08:55:01 [ERROR] connection error: unknown error Post "http://127.0.0.1:5985/wsman": read tcp 127.0.0.1:56622->127.0.0.1:5985: read: connection reset by peer 2021/01/13 08:55:01 packer-builder-xenserver-iso: 2021/01/13 08:55:01 [ERROR] WinRM connection err: unknown error Post "http://127.0.0.1:5985/wsman": read tcp 127.0.0.1:56622->127.0.0.1:5985: read: connection reset by peer 2021/01/13 08:55:06 packer-builder-xenserver-iso: 2021/01/13 08:55:06 [INFO] Attempting WinRM connection... 2021/01/13 08:55:06 packer-builder-xenserver-iso: 2021/01/13 08:55:06 [DEBUG] connecting to remote shell using WinRM 2021/01/13 08:55:07 packer-builder-xenserver-iso: 2021/01/13 08:55:07 ssh.Dial error: ssh: rejected: administratively prohibited (open failed) 2021/01/13 08:55:07 packer-builder-xenserver-iso: 2021/01/13 08:55:07 [ERROR] connection error: unknown error Post "http://127.0.0.1:5985/wsman": read tcp 127.0.0.1:56636->127.0.0.1:5985: read: connection reset by peer 2021/01/13 08:55:07 packer-builder-xenserver-iso: 2021/01/13 08:55:07 [ERROR] WinRM connection err: unknown error Post "http://127.0.0.1:5985/wsman": read tcp 127.0.0.1:56636->127.0.0.1:5985: read: connection reset by peer 2021/01/13 08:55:12 packer-builder-xenserver-iso: 2021/01/13 08:55:12 [INFO] Attempting WinRM connection... 2021/01/13 08:55:12 packer-builder-xenserver-iso: 2021/01/13 08:55:12 [DEBUG] connecting to remote shell using WinRM 2021/01/13 08:55:12 packer-builder-xenserver-iso: 2021/01/13 08:55:12 ssh.Dial error: ssh: rejected: administratively prohibited (open failed) 2021/01/13 08:55:12 packer-builder-xenserver-iso: 2021/01/13 08:55:12 [ERROR] connection error: unknown error Post "http://127.0.0.1:5985/wsman": read tcp 127.0.0.1:56644->127.0.0.1:5985: read: connection reset by peer 2021/01/13 08:55:12 packer-builder-xenserver-iso: 2021/01/13 08:55:12 [ERROR] WinRM connection err: unknown error Post "http://127.0.0.1:5985/wsman": read tcp 127.0.0.1:56644->127.0.0.1:5985: read: connection reset by peer 2021/01/13 08:55:17 packer-builder-xenserver-iso: 2021/01/13 08:55:17 [INFO] Attempting WinRM connection... 2021/01/13 08:55:17 packer-builder-xenserver-iso: 2021/01/13 08:55:17 [DEBUG] connecting to remote shell using WinRM 2021/01/13 08:55:17 packer-builder-xenserver-iso: 2021/01/13 08:55:17 ssh.Dial error: ssh: rejected: administratively prohibited (open failed) 2021/01/13 08:55:17 packer-builder-xenserver-iso: 2021/01/13 08:55:17 [ERROR] connection error: unknown error Post "http://127.0.0.1:5985/wsman": read tcp 127.0.0.1:56668->127.0.0.1:5985: read: connection reset by peer 2021/01/13 08:55:17 packer-builder-xenserver-iso: 2021/01/13 08:55:17 [ERROR] WinRM connection err: unknown error Post "http://127.0.0.1:5985/wsman": read tcp 127.0.0.1:56668->127.0.0.1:5985: read: connection reset by peer 2021/01/13 08:55:22 packer-builder-xenserver-iso: 2021/01/13 08:55:22 [INFO] Attempting WinRM connection... 2021/01/13 08:55:22 packer-builder-xenserver-iso: 2021/01/13 08:55:22 [DEBUG] connecting to remote shell using WinRM 2021/01/13 08:55:22 packer-builder-xenserver-iso: 2021/01/13 08:55:22 ssh.Dial error: ssh: rejected: administratively prohibited (open failed) 2021/01/13 08:55:22 packer-builder-xenserver-iso: 2021/01/13 08:55:22 [ERROR] connection error: unknown error Post "http://127.0.0.1:5985/wsman": read tcp 127.0.0.1:56690->127.0.0.1:5985: read: connection reset by peer 2021/01/13 08:55:22 packer-builder-xenserver-iso: 2021/01/13 08:55:22 [ERROR] WinRM connection err: unknown error Post "http://127.0.0.1:5985/wsman": read tcp 127.0.0.1:56690->127.0.0.1:5985: read: connection reset by peer 2021/01/13 08:55:27 packer-builder-xenserver-iso: 2021/01/13 08:55:27 [INFO] Attempting WinRM connection...

ddelnano commented 3 years ago

@fanuelsen can you explain what hosts are 192.168.1.20 and 192.168.1.21 are? It seems the latter is the VM that was launched (and where the ssh port forwarding was done to).

fanuelsen commented 3 years ago

192.168.1.20 = XCP-NG Poolmaster 192.168.1.21 = XCP-NG slave 192.168.1.22 = Virtual machine

I'm not sure how the xenserver-iso builder works, but in my opinion it should do the winrm connection to virtual machine? At least thats how to vsphere-iso works.

Also if i dont specify host_port_min and host_port_max it will try to connect to port 5900 the default for winrm is 5985 for insecure and 5986 for secure.

fanuelsen commented 3 years ago

After updating to latest builder version and packer 1.6.5 it looks better. winrm_use_ssl=true defaults to port 5986 without the need to specify the winrm port.

I still get this errors tough from the packerlog: 2021/01/20 14:18:22 packer-builder-xenserver-iso plugin: 2021/01/20 14:18:22 [INFO] Attempting WinRM connection... 2021/01/20 14:18:22 packer-builder-xenserver-iso plugin: 2021/01/20 14:18:22 [DEBUG] connecting to remote shell using WinRM 2021/01/20 14:18:22 packer-builder-xenserver-iso plugin: 2021/01/20 14:18:22 [ERROR] connection error: unknown error Post "https://:5986/wsman": dial tcp :5986: connect: connection refused 2021/01/20 14:18:22 packer-builder-xenserver-iso plugin: 2021/01/20 14:18:22 [ERROR] WinRM connection err: unknown error Post "https://:5986/wsman": dial tcp :5986: connect: connection refused

looks like its not fetching the VM ip when using winrm?

ddelnano commented 3 years ago

Glad that the upgrade made things a bit better and appreciate all the information you've contributed. I'm going to give this attention but unfortunately it probably won't be until next month (other terraform-provider-xenorchestra work is in progress).

fanuelsen commented 3 years ago

Thats ok, Just glad someone picked this up :) I will probably use your terraform provider later in a follow up project to this one.

Another thought, would it be better for a future xenserver packer builder to use xenorchestra? If they have a more consistant API than XAPI? Would need a XOA server so may be too much backend for some people to just run packer for easy image creation.

ddelnano commented 3 years ago

@fanuelsen that was something I considered but there are some things that are missing from the XO api that would need to be implemented in order to have the packer builder work with kickstart / autoinstall (typing a boot command over vnc). I've given this feedback to the XO team (as they are sponsoring my open source work on this project and the Xen Orchestra terraform provider).

So there is a possibility but at the time it was easier to build on the previous xenserver packer builder.

fanuelsen commented 3 years ago

@ddelnano I agree in the future support for XO will make more sense. But atm it would probably be faster to get the current version of the builder working directly with xcp-ng / xenserver. Looking forward to when you get some more time to work on this. I will gladly help out with testing and such. My programming skills are poor i'm sorry to say. But if you point me in the right direction i maybe able to try building the plugin from source and do some changes to the winrm part.

ddelnano commented 3 years ago

Appreciate that you are able to help with testing. I will likely ask for that help once I've made some progress on this.

I don't think I will have time to look into this during February (like I originally planned) but I will make sure to give it attention in March.

leeej84 commented 1 year ago

At present you cannot really use this for building Windows VM's but its definitely something that would be worth while. I am a Citrix CTP so have a bit of a direct link into Citrix. Happy to help with any feedback or information you feel you need to get this up and running.

d834256 commented 9 months ago

missing from the XO api that would need to be implemented in order to have the packer builder work with kickstart / autoinstall (typing a boot command over vnc). I've given this feedback to the XO team (as they are sponsoring my open source work on this project and the Xen Orchestra terraform provider).

What's the current state of this feature request?

From the limited testing I've done today I've not been able to get boot_command to work at all. Yet it's mentioned in the documentation here ->

https://github.com/ddelnano/packer-plugin-xenserver/blob/main/docs/builders/iso/xenserver-iso.html.markdown

I'm just a bit concerned what other features I might be expecting to use aren't ready for prime time yet.

CoolReaper commented 6 months ago

I'm able to install windows up to the point where WinRM must be used. We have CIS policies implemented, so I must use SSL. Still... I've tried multiple approaches... I don't seem to be able to connect. Keep on getting this:

2024/03/26 14:09:53 packer-plugin-xenserver_v0.7.0_x5.0_windows_amd64.exe plugin: 2024/03/26 14:09:53 [INFO] Attempting WinRM connection... 2024/03/26 14:09:53 packer-plugin-xenserver_v0.7.0_x5.0_windows_amd64.exe plugin: 2024/03/26 14:09:53 [DEBUG] connecting to remote shell using WinRM 2024/03/26 14:09:53 packer-plugin-xenserver_v0.7.0_x5.0_windows_amd64.exe plugin: 2024/03/26 14:09:53 [ERROR] connection error: http response error: 401 - invalid content type 2024/03/26 14:09:53 packer-plugin-xenserver_v0.7.0_x5.0_windows_amd64.exe plugin: 2024/03/26 14:09:53 [ERROR] WinRM connection err: http response error: 401 - invalid content type

However I'm able to connect manually using enter-pssession or invoke-command. I've tried looking into the code, to see what could be missing, but I'm too newbie to understand. I've looked into repositories of people saying they had fixed it, but I don't see any major references to winrm other than on the common-config.go file a mention to not ask for ssh_username when communicator is winrm.

CoolReaper commented 6 months ago

Ok... figured out it was my bad. WinRM does work, as well as SSH (tested with both) with Windows. Both when starting a build from windows as well as building a windows operating system from ISO.

olivierlambert commented 6 months ago

So is there anything specific to do before closing this issue?

CoolReaper commented 6 months ago

just one thing. That when communicator is specified as winrm, that we're not obliged to insert ssh credentials (ssh_username) on the config.