Closed leonyu closed 6 years ago
I'm not sure if this is a bug or unclear documentation -- If you provide your own restart check command, the provisioner runs both yours and our default one; this is because we've found that if we don't run our default, we run into an issue where windows will restart and start running the next provisioner before powershell modules are fully loaded. Can you please provide your debug logs (set PACKER_LOG=1 in your environment) and show me what you're seeing?
My JSON is pretty much what I pasted above.
{
"builders": [
{
"type": "virtualbox-ovf",
"source_path": "output-stage2/output-stage2.ovf",
"shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c Packer_Provisioning_Shutdown",
"guest_additions_mode": "disable",
"output_directory": "output-stage3",
"vm_name": "output-stage3",
"ssh_timeout": "10m",
"ssh_username": "owner",
"ssh_password": "owner"
}
],
"provisioners": [
{
"type": "windows-restart",
"restart_command": "echo restart",
"restart_check_command": "echo check"
}
]
}
This looks like the normal logs, not the debug logs. Did you set the env var PACKER_LOG=1?
Oops, sorry. Had to jump thru hoops to get Windows to pipe both stdout and stderr to the same file, Didn't realize the context I was running from didn't inherit it.
Oddly the command (shutdown.exe -f -r -t 60
) works if I invoke it via SSH manually:
Thanks for the updated logs!
@leonyu upon revisiting this ticket, I'm confused... why are you trying to use the windows_restart
provisioner on a linux guest? It's specifically for restarting windows guests.
packer.zip Can you try this build for me? It's a build of https://github.com/hashicorp/packer/pull/6112
The Linux target was solely for debugging to see what SSH command was being pass in. I will try the new build when I get home.
It would appear 1.2.2 or the .zip build provided is unusable for my attempted configuration -- Using SSH instead of WinRM as communicator for Windows on VirtualBox
Build 'virtualbox-ovf' errored: Error uploading VirtualBox version: test : The term 'test' is not recognized as the name of a cmdlet, function,
script file, or operable program. Check the spelling of the name, or if a path
was included, verify that the path is correct and try again.
At line:1 char:1
+ test -d .vbox_version
+ ~~~~
+ CategoryInfo : ObjectNotFound: (test:String) [], CommandNotFoun
dException
+ FullyQualifiedErrorId : CommandNotFoundException
I assume test -d .vbox_version
is a bash/Linux command looking for Vbox Guest additions. This was produce with a Windows 2008 Server JSON file with no provisioner and SSH communicator.
If I get a chance will try produce a JSON fie based on trial ISOs that I can publish publicly.
The reason I am trying to use SSH on Windows is because I need to transfer large files in latter steps of my build, which takes a long time in WinRM.
Sorry, that's a known bug I've been meaning to fix. I'll prioritize it for the next release. Are you trying to upload .vbox_version into a directory? If so, you can work around it in the meantime by being explicit about ending the destination directory with a /
. e.g. /path/to/my_directory/
instead of /path/to/my_directory
oh, nevermind -- this is a bug specific to virtualbox. Fixing now.
Okay, sorry about that. Can you try this one? packer.zip
Doesn't appear to fix the issue of the "shutdown help" spam.
I have created a stripped down version of my build here: https://bitbucket.org/leonyu-net/packer-win2k8
You should be able to reproduce the problem with packer build stage1-packer.json
then packer build stage2-packer.json
. Stage 1 builds an OVF with OpenSSH, Stage 2 simply attempts to use the OVF with windows-restart
, but will produce the described behavior (shutdown help spam).
Right now the default shell is set to PowerShell, but the error existed with CMD, at least in previous version.
NOTE: First stage takes half an hour to an hour to build. It also download the Windows 2008 evaluation ISO and a few big updates (.NET 4.7, WMF 5, Rollup update)
Thanks.
Hmm... I'm unable to get your repro case working because the openssh install fails:
2018/04/09 12:21:50 ui: virtualbox-iso: Downloading OpenSSH Server (sshd)
virtualbox-iso: Downloading OpenSSH Server (sshd)
2018/04/09 12:21:50 packer: 2018/04/09 12:21:50 [INFO] RPC client: Communicator ended with: 1
2018/04/09 12:21:50 ui: virtualbox-iso: Exception setting "SecurityProtocol": "Cannot convert null to type "System.Net.
virtualbox-iso: Exception setting "SecurityProtocol": "Cannot convert null to type "System.Net.
2018/04/09 12:21:50 ui: virtualbox-iso: SecurityProtocolType" due to invalid enumeration values. Specify one of the fol
virtualbox-iso: SecurityProtocolType" due to invalid enumeration values. Specify one of the fol
2018/04/09 12:21:50 ui: virtualbox-iso: lowing enumeration values and try again. The possible enumeration values are "S
virtualbox-iso: lowing enumeration values and try again. The possible enumeration values are "S
2018/04/09 12:21:50 ui: virtualbox-iso: sl3, Tls"."
virtualbox-iso: sl3, Tls"."
2018/04/09 12:21:50 ui: virtualbox-iso: At C:\Windows\Temp\script-5acbb9e9-0418-9df3-b8fc-66b291ef5964.ps1:16 char:35
virtualbox-iso: At C:\Windows\Temp\script-5acbb9e9-0418-9df3-b8fc-66b291ef5964.ps1:16 char:35
2018/04/09 12:21:50 ui: virtualbox-iso: + [System.Net.ServicePointManager]:: <<<< SecurityProtocol = [System.Net.Securi
virtualbox-iso: + [System.Net.ServicePointManager]:: <<<< SecurityProtocol = [System.Net.Securi
2018/04/09 12:21:50 ui: virtualbox-iso: tyProtocolType]::Tls12;
virtualbox-iso: tyProtocolType]::Tls12;
2018/04/09 12:21:50 ui: virtualbox-iso: + CategoryInfo : InvalidOperation: (:) [], ParentContainsErrorRec
virtualbox-iso: + CategoryInfo : InvalidOperation: (:) [], ParentContainsErrorRec
2018/04/09 12:21:50 ui: virtualbox-iso: ordException
virtualbox-iso: ordException
2018/04/09 12:21:50 ui: virtualbox-iso: + FullyQualifiedErrorId : PropertyAssignmentException
virtualbox-iso: + FullyQualifiedErrorId : PropertyAssignmentException
2018/04/09 12:21:50 ui: virtualbox-iso:
In the meantime though, I'm wondering whether this is really the root issue. it isn't RestartCheckCommand that's failing, by the way -- it's an internal value, TryCheckReboot. TryCheckReboot is spammy by nature because it should eventually get cut off when the computer actually, successfully, reboots. In your example case above, this never happens because "echo restart" isn't a valid restart command. My guess is that the restart_command you're overwriting "for real" isn't valid either, though I can't vet it since you didn't share it.
Looks like .NET 4.7 upgrade didn't go through, Windows 2008 R2 only comes with TLS 1.0 support for PowerShell/.NET. GitHub has disabled TLS 1.0 last year (minimum TLS 1.1).
I can upload my ovf
to S3 when I get home today.
Here's a prebuilt stage one http://www.voidvector.com/output-stage1.tar.gz
You can untar it in the same folder (should create a output-stage1
with ovf and vmdk under it) and run packer build stage2-packer.json
build directly.
test -d
bugThanks, I can repro based on that.
Unfortunately, I also did some research and realized this is ultimately not going to work for you; the windows-restart provisioner was written specifically for winRM, in order to work around the fact that it can't handle disconnects.
However, Packer's ssh communicator, which you're using, can handle restarts. See this thread for context. Linked there is an example of how reboots are managed before OpenSSH is connected (though you've managed this with your stage-1 build). When you're connected via SSH, your best option is unfortunately the one outlined in https://github.com/hashicorp/packer/issues/1983#issuecomment-81978106
I'm going to close this for now, since nothing's really changed since Mitchell closed #1983.
HOWEVER, if you're able to successfully work around the "restart_command" double-escaping madness and find something that actually works...
(a) I'd love to hear about it so I can implement it for the SSH communicator and make windows-restart more useful to SSH-sers, and
(b) it will make the spamminess from that "TryCheckReboot" command not actually an issue. It'll be annoying, but it isn't the root problem. The fact that the restart_command is generating the same help menu instead of actually restarting the computer is the problem.
All this said, I've built you a new Packer binary that'll reduce the spamminess from the TryCheckReboot command to make it easier for you to find and focus on the restart_check command. packer.zip
Thank you for the investigation!! Really appreciate it.
I will try with suggestion in linked ticket.
On Tue, Apr 10, 2018, 2:14 PM M. Marsh notifications@github.com wrote:
I'm going to close this for now, since nothing's really changed since Mitchell closed #1983 https://github.com/hashicorp/packer/issues/1983.
HOWEVER, if you're able to successfully work around the "restart_command" double-escaping madness and find something that actually works...
(a) I'd love to hear about it so I can implement it for the SSH communicator and make windows-restart more useful to SSH-sers, and
(b) it will make the spamminess from that "TryCheckReboot" command not actually an issue. It'll be annoying, but it isn't the root problem. The fact that the restart_command is generating the same help menu instead of actually restarting the computer is the problem.
All this said, I've built you a new Packer binary that'll reduce the spamminess from the TryCheckReboot command to make it easier for you to find and focus on the restart_check command. packer.zip https://github.com/hashicorp/packer/files/1895854/packer.zip
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/hashicorp/packer/issues/6055#issuecomment-380197416, or mute the thread https://github.com/notifications/unsubscribe-auth/AASnBs-vhxVV6aqRLK1CRgzF34W5v-opks5tnPaYgaJpZM4S6UAm .
I've just made a PR I think may actually fix this. See the above link.
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
windows-restart
provisioner does not respectrestart_check_command
when using SSH communicator.Instead of trying to execute provided
restart_check_command
in a loop, it would attempt to execute the default command, and flooded the console with its infinite attempts to executeshutdown.exe
.Sample JSON
Context:
Due to command escape bug in the current Win32-OpenSSH server implementation (https://github.com/PowerShell/Win32-OpenSSH/issues/1082), I have to override the built-in
windows-restart
commands when using SSH communicator on a guest with Win32-OpenSSH; however, this Packer bug is preventing me from doing so.