Hi all,
I am using packer to install Windows XP and Windows Vista. Everything is going smoothly until provisioners
scripts start running. When a script runs, packer returns a successful exit code but the script doesn’t actually execute.
Here’s the most minimalistic example:
"provisioners": [
{
"type" : "windows-shell",
"inline": [ "echo hello" ],
}
]
And here’s the output from packer (below). As you can see, it puts echo hello
(line [4]) in c:/Windows/Temp/script.bat
(line [9]) and then runs it, but it doesn’t actually execute. You can see that hello
was not sent to stdout and also the log says 0 bytes were written to stdout (line [13]).
[1] ==> qemu: Connected to WinRM!
[2] 2023/08/23 21:51:54 packer-builder-qemu plugin: Running the provision hook
[3] ==> qemu: Provisioning with windows-shell...
[4] 2023/08/23 21:51:54 packer-provisioner-windows-shell plugin: Found command: echo hello
[5] ==> qemu: Provisioning with shell script: /tmp/windows-shell-provisioner150715501
[6] 2023/08/23 21:51:54 packer-provisioner-windows-shell plugin: Opening /tmp/windows-shell-provisioner150715501 for reading
[7] 2023/08/23 21:51:54 packer-provisioner-windows-shell plugin: [INFO] 11 bytes written for 'uploadData'
[8] 2023/08/23 21:51:54 [INFO] 11 bytes written for 'uploadData'
[9] 2023/08/23 21:51:54 packer-builder-qemu plugin: Uploading file to 'c:/Windows/Temp/script.bat'
[10] 2023/08/23 21:51:56 packer-builder-qemu plugin: [INFO] starting remote command: set "PACKER_BUILDER_TYPE=qemu" && set "PACKER_BUILD_NAME=qemu" && set "PACKER_HTTP_ADDR=10.0.2.2:0" && set "PACKER_HTTP_IP=10.0.2.2" && set "PACKER_HTTP_PORT=0" && "c:/Windows/Temp/script.bat"
[11] 2023/08/23 21:51:56 packer-builder-qemu plugin: [INFO] command 'set "PACKER_BUILDER_TYPE=qemu" && set "PACKER_BUILD_NAME=qemu" && set "PACKER_HTTP_ADDR=10.0.2.2:0" && set "PACKER_HTTP_IP=10.0.2.2" && set "PACKER_HTTP_PORT=0" && "c:/Windows/Temp/script.bat"' exited with code: 0
[12] 2023/08/23 21:51:56 packer-builder-qemu plugin: [INFO] RPC endpoint: Communicator ended with: 0
[13] 2023/08/23 21:51:56 [INFO] 0 bytes written for 'stdout'
[14] 2023/08/23 21:51:56 [INFO] 0 bytes written for 'stderr'
[15] 2023/08/23 21:51:56 [INFO] RPC client: Communicator ended with: 0
[16] 2023/08/23 21:51:56 [INFO] RPC endpoint: Communicator ended with: 0
[17] 2023/08/23 21:51:56 packer-provisioner-windows-shell plugin: [INFO] 0 bytes written for 'stdout'
[18] 2023/08/23 21:51:56 packer-provisioner-windows-shell plugin: [INFO] 0 bytes written for 'stderr'
[19] 2023/08/23 21:51:56 packer-provisioner-windows-shell plugin: [INFO] RPC client: Communicator ended with: 0
[20] ==> qemu: Gracefully halting virtual machine...
Similarly, if I use any other command (I have a dozen scripts that need to run to provision XP and Vista), all the commands succeed with error code 0
but none of them run.
I also tried connecting to WinRM via pywinrm
(pywinrm · PyPI) and the script in c:/Windows/Temp/script.bat
runs successfully if run it via the most basic pywinrm snippet:
>>> import winrm
>>> s = winrm.Session('127.0.0.1:2924', auth=('user1', 'user1'))
>>> r = s.run_cmd('cmd', ['/c', 'c:/Windows/Temp/script.bat'])
>>> r.status_code
0
>>> r.std_out
b'\r\nC:\\Documents and Settings\\user1>echo hello \r\nhello\r\n'
And just an additional comment – packer works great on all other modern systems that we have, such as Windows 7, and Windows 10. Only these two older systems, XP and Vista, are affected.
Does anyone have an idea what could be blocking the c:/Windows/Temp/script.bat
script from executing? Perhaps it’s some hidden Windows or WinRM permission or group policy restriction on these older systems?
Thank you!
Sincerely,
Peter Krumins