mefellows / vagrant-windows-domain

Connects & removes your Windows Vagrant box from a Domain
MIT License
31 stars 8 forks source link

Box restarts even if provisioning fails #1

Open mefellows opened 9 years ago

mefellows commented 9 years ago

If provisioning fails, the box restart is still performed.

It seems that the run_remote_command_runner method in provisioner.rb never returns an error code > 0 (even if powershell script fails), which is likely the main issue.

mefellows commented 9 years ago

Closed due to #7.

Exit codes are now determined by presence or lack-thereof of :stderr responses. Box will not restart if machine provisioning fails.

mefellows commented 9 years ago

I had to re-instate the use of the sudo shell method to ensure the command is run as an elevated user. This has had a knock-on effect that detecting a valid exit code is now even more difficult than before.

As an example, we now have nicely formatted output but when a command fails we cannot detect it (and color is not red):

==> default: "Running Windows Domain Provisioner"
VERBOSE: Performing the operation "Join in domain 'seek.int'" on target "talentsearchapi".Add-Computer : Computer 'talentsearchapi' failed to join domain 'seek.int'
from its current workgroup 'WORKGROUP' with following error message: Access is
denied.
At C:\tmp\vagrant-windows-domain-runner.ps1:3 char:1
+ Add-Computer -DomainName seek.int -Credential $credentials -NewName
'tsapi7d66ef ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (talentsearchapi:String) [Add-
   Computer], InvalidOperationException
    + FullyQualifiedErrorId : FailToJoinDomainFromWorkgroup,Microsoft.PowerShe
   ll.Commands.AddComputerCommand
 Restarting computer for updates to take effect.