StefanScherer / packer-windows

Windows Templates for Packer: Windows 11, Windows 10, Windows Server 2022, 2019, 2016, also with Docker
MIT License
1.29k stars 431 forks source link

Reintroduce SSH to Windows boxes? #84

Closed StefanScherer closed 5 years ago

StefanScherer commented 6 years ago

With the problem in #83 to mount the shared folder for some Serverspec tests in a Jenkins build agent environment I also tried another option.

I changed the default shared folder to an rsync synced folder

config.vm.synced_folder ".", "/vagrant", type: "rsync", rsync__exclude: ".git/"

But then the next Jenkins build aborts with an error. Oh man, of course, the Windows VM does not have SSH and rsync installed. 😅

[windows_2016_docker]     tst: Setting VM Integration Services
[windows_2016_docker]     tst: Successfully imported a VM with name: WindowsServer2016Docker
[windows_2016_docker] ==> tst: Starting the machine...
[windows_2016_docker] ==> tst: Waiting for the machine to report its IP address...
[windows_2016_docker]     tst: Timeout: 120 seconds
[windows_2016_docker]     tst: IP: 192.168.0.11
[windows_2016_docker] ==> tst: Waiting for machine to boot. This may take a few minutes...
[windows_2016_docker]     tst: WinRM address: 192.168.0.11:5985
[windows_2016_docker]     tst: WinRM username: vagrant
[windows_2016_docker]     tst: WinRM execution_time_limit: PT2H
[windows_2016_docker]     tst: WinRM transport: negotiate
[windows_2016_docker] ==> tst: Machine booted and ready!
[windows_2016_docker] ==> tst: Rsyncing folder: /cygdrive/c/Windows/workspace/packer-windows_my-PH7VQTN6RDUL23PJXSNDIGZXF5YME4XP2R3GVKXGJIWL7LIVCX5A/boxtest/ => /vagrant
[windows_2016_docker] ==> tst:   - Exclude: [".vagrant/", ".git/"]
[windows_2016_docker] There was an error when attempting to rsync a synced folder.
[windows_2016_docker] Please inspect the error message below for more info.
[windows_2016_docker] 
[windows_2016_docker] Host path: /cygdrive/c/Windows/workspace/packer-windows_my-PH7VQTN6RDUL23PJXSNDIGZXF5YME4XP2R3GVKXGJIWL7LIVCX5A/boxtest/
[windows_2016_docker] Guest path: /vagrant
[windows_2016_docker] Command: "rsync" "--verbose" "--archive" "--delete" "-z" "--copy-links" "--chmod=ugo=rwX" "--no-perms" "--no-owner" "--no-group" "-e" "ssh -p 22 -o LogLevel=FATAL   -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i 'C:/Users/demo/.vagrant.d/insecure_private_key'" "--exclude" ".vagrant/" "--exclude" ".git/" "/cygdrive/c/Windows/workspace/packer-windows_my-PH7VQTN6RDUL23PJXSNDIGZXF5YME4XP2R3GVKXGJIWL7LIVCX5A/boxtest/" "vagrant@192.168.0.11:/vagrant"
[windows_2016_docker] Error: This rsync lacks old-style --compress due to its external zlib.  Try -zz.
[windows_2016_docker] Continuing without compression.
[windows_2016_docker] 
[windows_2016_docker] rsync: connection unexpectedly closed (0 bytes received so far) [sender]
[windows_2016_docker] rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
[windows_2016_docker] 

Well, the upstream repo still has the (non-Microsoft) OpenSSH as communicator and you also can install an rsync binary. Microsoft's OpenSSH native port has reached 1.0.0 (still not production ready).

2018 - the return of SSH in packer-windows boxes? 😂

StefanScherer commented 6 years ago

Upstream packer-windows uses OpenSSH, eg.

The steps highlighted in the following script install and configure the Microsoft native port of OpenSSH

Packer could still use WinRM communicator and just additionally install the SSH service.

StefanScherer commented 5 years ago

Currently the WinRM communicator is the better way to do it.