hashicorp / packer-plugin-googlecompute

Packer plugin for Google Compute Builder
https://www.packer.io/docs/builders/googlecompute
Mozilla Public License 2.0
23 stars 51 forks source link

Windows over WinSSH with ansible provisioner #172

Open magustin-telus opened 1 year ago

magustin-telus commented 1 year ago

Overview of the Issue

sysprep commands from documentation to enable SSH not working.

Reproduction Steps

followed the documentation from https://developer.hashicorp.com/packer/plugins/builders/googlecompute#windows-over-winssh-ansible-provisioner

using GCP windows image windows-server-2019-dc-v20230510

Plugin and Packer version

packer version 1.9.1

Simplified Packer Buildfile

buildfile is the same as the documentation

2023/06/16 19:43:45 GCEMetadataScripts: sysprep-specialize-script-cmd: The user or group account specified cannot be found.
2023/06/16 19:43:45 GCEMetadataScripts: sysprep-specialize-script-cmd: The user was successfully created but could not be added
2023/06/16 19:43:45 GCEMetadataScripts: sysprep-specialize-script-cmd: to the USERS local group.

2023/06/16 19:47:45 GCEMetadataScripts: sysprep-specialize-script-cmd: New-NetFirewallRule : Cannot create a file when that file already exists.
2023/06/16 19:47:45 GCEMetadataScripts: sysprep-specialize-script-cmd: At line:1 char:1
2023/06/16 19:47:45 GCEMetadataScripts: sysprep-specialize-script-cmd: + New-NetFirewallRule -Name 'OpenSSH-Server-In-TCP' -DisplayName 'OpenS ...
2023/06/16 19:47:45 GCEMetadataScripts: sysprep-specialize-script-cmd: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2023/06/16 19:47:45 GCEMetadataScripts: sysprep-specialize-script-cmd:     + CategoryInfo          : ResourceExists: (MSFT_NetFirewallRule:root/st
2023/06/16 19:47:45 GCEMetadataScripts: sysprep-specialize-script-cmd:    andardcimv2/MSFT_NetFirewallRule) [New-NetFirewallRule], CimException
2023/06/16 19:47:45 GCEMetadataScripts: sysprep-specialize-script-cmd:     + FullyQualifiedErrorId : Windows System Error 183,New-NetFirewallRule
lmayorga1980 commented 7 months ago

Currently, i am experiencing the same issue with packer 1.9.4 and image windows-server-2019-dc-v20231115

smartyr73 commented 6 months ago

The latest Google Windows base images come with openSSH by default. Just need to enable at runtime.

https://cloud.google.com/compute/docs/connect/windows-ssh

Just include this in the Packer template file:

metadata = { “sysprep-specialize-script-cmd” = “googet -noconfirm=true update && googet -noconfirm=true install google-compute-engine-ssh" "enable-windows-ssh" = "TRUE" }

Set SSH communicators as normal

https://developer.hashicorp.com/packer/docs/communicators/ssh

Bear in mind it's still in preview though.