Skip to content

provision-openssh.ps1 fails when run from autounattend #28

@velvetant

Description

@velvetant

I noticed OpenSSH not being installed even though the builds ran through fine. In the setupact.log everything seems to be fine. When run manually the script runs through without problems as well. I don't know how to get more verbose logging :/

My workaround so far is to comment it out in provision-autounattend.ps1 and run it as a packer provision step.
Edit: oh, that fails as well with curious reasons for doing so:

==> proxmox-iso.windows-10-21h2-amd64: Provisioning with powershell script: ../scripts/provision-openssh.ps1
2023/04/11 19:48:12 packer-provisioner-powershell plugin: Opening ../scripts/provision-openssh.ps1 for reading
2023/04/11 19:48:12 packer-provisioner-powershell plugin: Uploading env vars to c:/Windows/Temp/packer-ps-env-vars-64359d5c-af82-c4bb-31a9-195b1e873f36.ps1
2023/04/11 19:48:12 packer-provisioner-powershell plugin: [INFO] 118 bytes written for 'uploadData'
2023/04/11 19:48:12 [INFO] 118 bytes written for 'uploadData'
2023/04/11 19:48:12 packer-plugin-proxmox_v1.1.2_x5.0_linux_amd64 plugin: 2023/04/11 19:48:12 Uploading file to 'c:/Windows/Temp/packer-ps-env-vars-64359d5c-af82-c4bb-31a9-195b1e873f36.ps1'
2023/04/11 19:48:22 packer-provisioner-powershell plugin: [INFO] 6062 bytes written for 'uploadData'
2023/04/11 19:48:22 [INFO] 6062 bytes written for 'uploadData'
2023/04/11 19:48:22 packer-plugin-proxmox_v1.1.2_x5.0_linux_amd64 plugin: 2023/04/11 19:48:22 Uploading file to 'c:/Windows/Temp/script-64359d5c-f051-c72a-b84f-495c81f719c3.ps1'
2023/04/11 19:48:57 packer-plugin-proxmox_v1.1.2_x5.0_linux_amd64 plugin: 2023/04/11 19:48:57 [INFO] starting remote command: pwsh -executionpolicy bypass -command "& { if (Test-Path variable:global:ProgressPreference){set-variable -name variable:global:ProgressPreference -value 'SilentlyContinue'};. c:/Windows/Temp/packer-ps-env-vars-64359d5c-af82-c4bb-31a9-195b1e873f36.ps1; &'c:/Windows/Temp/script-64359d5c-f051-c72a-b84f-495c81f719c3.ps1'; exit $LastExitCode }"
2023/04/11 19:48:58 packer-plugin-proxmox_v1.1.2_x5.0_linux_amd64 plugin: 2023/04/11 19:48:58 [INFO] command 'pwsh -executionpolicy bypass -command "& { if (Test-Path variable:global:ProgressPreference){set-variable -name variable:global:ProgressPreference -value 'SilentlyContinue'};. c:/Windows/Temp/packer-ps-env-vars-64359d5c-af82-c4bb-31a9-195b1e873f36.ps1; &'c:/Windows/Temp/script-64359d5c-f051-c72a-b84f-495c81f719c3.ps1'; exit $LastExitCode }"' exited with code: 0
2023/04/11 19:48:58 packer-plugin-proxmox_v1.1.2_x5.0_linux_amd64 plugin: 2023/04/11 19:48:58 [INFO] RPC endpoint: Communicator ended with: 0
2023/04/11 19:48:58 [INFO] 0 bytes written for 'stdout'
2023/04/11 19:48:58 [INFO] 303 bytes written for 'stderr'
2023/04/11 19:48:58 [INFO] RPC client: Communicator ended with: 0
2023/04/11 19:48:58 [INFO] RPC endpoint: Communicator ended with: 0
2023/04/11 19:48:58 packer-provisioner-powershell plugin: [INFO] 0 bytes written for 'stdout'
2023/04/11 19:48:58 packer-provisioner-powershell plugin: [INFO] 303 bytes written for 'stderr'
2023/04/11 19:48:58 packer-provisioner-powershell plugin: [INFO] RPC client: Communicator ended with: 0
==> proxmox-iso.windows-10-21h2-amd64: .: The term 'c:/Windows/Temp/packer-ps-env-vars-64359d5c-af82-c4bb-31a9-195b1e873f36.ps1' is not recognized as a name of a cmdlet, function, script file, or executable program.
2023/04/11 19:48:58 packer-provisioner-powershell plugin: c:/Windows/Temp/script-64359d5c-f051-c72a-b84f-495c81f719c3.ps1 returned with exit code 0
==> proxmox-iso.windows-10-21h2-amd64: Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
2023/04/11 19:48:58 packer-provisioner-powershell plugin: [INFO] 511 bytes written for 'uploadData'
2023/04/11 19:48:58 [INFO] 511 bytes written for 'uploadData'
2023/04/11 19:48:58 packer-plugin-proxmox_v1.1.2_x5.0_linux_amd64 plugin: 2023/04/11 19:48:58 Uploading file to 'c:/Windows/Temp/packer-cleanup-64359d5c-9dcd-971a-6265-5b6602982e70.ps1'
2023/04/11 19:49:04 packer-plugin-proxmox_v1.1.2_x5.0_linux_amd64 plugin: 2023/04/11 19:49:04 [INFO] starting remote command: pwsh -executionpolicy bypass -command "& { if (Test-Path variable:global:ProgressPreference){set-variable -name variable:global:ProgressPreference -value 'SilentlyContinue'};. c:/Windows/Temp/packer-ps-env-vars-64359d5c-af82-c4bb-31a9-195b1e873f36.ps1; &'c:/Windows/Temp/packer-cleanup-64359d5c-9dcd-971a-6265-5b6602982e70.ps1'; exit $LastExitCode }"
2023/04/11 19:49:05 packer-plugin-proxmox_v1.1.2_x5.0_linux_amd64 plugin: 2023/04/11 19:49:05 [INFO] command 'pwsh -executionpolicy bypass -command "& { if (Test-Path variable:global:ProgressPreference){set-variable -name variable:global:ProgressPreference -value 'SilentlyContinue'};. c:/Windows/Temp/packer-ps-env-vars-64359d5c-af82-c4bb-31a9-195b1e873f36.ps1; &'c:/Windows/Temp/packer-cleanup-64359d5c-9dcd-971a-6265-5b6602982e70.ps1'; exit $LastExitCode }"' exited with code: 0
2023/04/11 19:49:05 packer-plugin-proxmox_v1.1.2_x5.0_linux_amd64 plugin: 2023/04/11 19:49:05 [INFO] RPC endpoint: Communicator ended with: 0
2023/04/11 19:49:05 [INFO] 0 bytes written for 'stdout'
2023/04/11 19:49:05 [INFO] 303 bytes written for 'stderr'
2023/04/11 19:49:05 [INFO] RPC client: Communicator ended with: 0
2023/04/11 19:49:05 [INFO] RPC endpoint: Communicator ended with: 0
2023/04/11 19:49:05 packer-provisioner-powershell plugin: [INFO] 0 bytes written for 'stdout'
2023/04/11 19:49:05 packer-provisioner-powershell plugin: [INFO] 303 bytes written for 'stderr'
2023/04/11 19:49:05 packer-provisioner-powershell plugin: [INFO] RPC client: Communicator ended with: 0
==> proxmox-iso.windows-10-21h2-amd64: .: The term 'c:/Windows/Temp/packer-ps-env-vars-64359d5c-af82-c4bb-31a9-195b1e873f36.ps1' is not recognized as a name of a cmdlet, function, script file, or executable program.
2023/04/11 19:49:05 [INFO] (telemetry) ending powershell
==> proxmox-iso.windows-10-21h2-amd64: Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
==> proxmox-iso.windows-10-21h2-amd64: Stopping VM

After switching on the debug flags, it shows the script silently exiting after

    proxmox-iso.windows-10-21h2-amd64: DEBUG:   70+  >>>> $windowsOpenSshCapabilities = Get-WindowsCapability -Online -Name 'OpenSSH.*' | Where-Object {$_.State -ne 'NotPresent'}
    proxmox-iso.windows-10-21h2-amd64: 
2023/04/12 00:13:00 packer-plugin-proxmox_v1.1.2_x5.0_linux_amd64 plugin: 2023/04/12 00:13:00 [INFO] command 'pwsh -executionpolicy bypass -command "& { if (Test-Path variable:global:ProgressPreference){set-variable -name variable:global:ProgressPreference -value 'SilentlyContinue'};Set-PsDebug -Trace 1;. c:/Windows/Temp/packer-ps-env-vars-6435db5a-c007-eecc-99ad-e36c813e4adf.ps1; &'c:/Windows/Temp/script-6435db5a-586f-9950-b5e0-c9f1c873fcf8.ps1'; exit $LastExitCode }"' exited with code: 0
2023/04/12 00:13:00 packer-plugin-proxmox_v1.1.2_x5.0_linux_amd64 plugin: 2023/04/12 00:13:00 [INFO] RPC endpoint: Communicator ended with: 0
2023/04/12 00:13:00 [INFO] 4119 bytes written for 'stdout'
2023/04/12 00:13:00 [INFO] 0 bytes written for 'stderr'
2023/04/12 00:13:00 [INFO] RPC client: Communicator ended with: 0
2023/04/12 00:13:00 [INFO] RPC endpoint: Communicator ended with: 0
2023/04/12 00:13:00 packer-provisioner-powershell plugin: [INFO] 4119 bytes written for 'stdout'
2023/04/12 00:13:00 packer-provisioner-powershell plugin: [INFO] 0 bytes written for 'stderr'
2023/04/12 00:13:00 packer-provisioner-powershell plugin: [INFO] RPC client: Communicator ended with: 0
2023/04/12 00:13:00 packer-provisioner-powershell plugin: c:/Windows/Temp/script-6435db5a-586f-9950-b5e0-c9f1c873fcf8.ps1 returned with exit code 0
2023/04/12 00:13:00 [INFO] (telemetry) ending powershell
==> proxmox-iso.windows-10-21h2-amd64: Stopping VM

as said, manually, there are no hickups. I wonder which account actually runs the script, a) in the autoattend.xml b) as a packer provisioner step.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions