Repository navigation
Description
The function _parse_powershell_list does not parse errors returned by PowerShell or the ServerManager PS module, which results in confusing error messages in the Salt user interface. For example, instead of telling the Salt user that a computer is in a post-restart-pending-action state (e.g., after removing a server role), the Salt user interface reports an IndexError in an assignment operation in _parse_powershell_list. Instead, Salt should relay the PowerShell error message (e.g., that a particular user needs to log into the computer and run Server Manager to complete the configuration change), as this clearly indicates what went wrong and how to remediate the error condition.
Steps to Reproduce
Given a computer running a full installation of Windows Server 2008 R2 Standard Edition (with all patches applied) and version 2014.1.11 of the Salt minion (latest version at time of writing), with the minion ID of minion-id:
-
Install the Web Server role interactively via Server Manager.
-
Remove the Web Server role interactively via Server Manager.
-
Reboot when prompted.
-
Do not log into the computer once it finishes booting.
-
From the Salt master, run the following command to re-install the Web Server role:
salt minion-id state.single win_servermanager.installed name=Web-Server -
The above command will return the following error:
ID: Web-Server Function: win_servermanager.installed Result: False Comment: An exception occurred in this state: Traceback (most recent call last): File "salt/state.py", line 1379, in call File "salt/states/win_servermanager.py", line 51, in installed File "c:\salt\var\cache\salt\minion\extmods\modules\win_servermanager.py", line 97, in install return _parse_powershell_list(out) File "c:\salt\var\cache\salt\minion\extmods\modules\win_servermanager.py", line 35, in _parse_powershell_list ret[splt[0]] = splt[2] IndexError: list index out of range Changes: -
From the Salt master, run the following PowerShell command to re-install the Web Server role (which simulates the behavior of the win_servermanager.installed state):
salt minion-id cmd.run 'Import-Module ServerManager ; Add-WindowsFeature -Name Web-Server -erroraction silentlycontinue | format-list' shell=powershell -
The above command will return the following error:
Add-WindowsFeature : A configuration started by EXAMPLE\Administrator is current ly in progress. Before you can start a configuration, EXAMPLE\Administrator must log in to complete the current configuration or the configuration in progress must be canceled. At line:1 char:49 + Import-Module ServerManager ; Add-WindowsFeature <<<< -Name Web-Server -err oraction silentlycontinue | format-list + CategoryInfo : OperationStopped: (:) [Add-WindowsFeature], Exce ption + FullyQualifiedErrorId : PostRestartPendingAction,Microsoft.Windows.Serve rManager.Commands.AddWindowsFeatureCommand -
Log into the computer and acknowledge the Server Manager role removal.
-
Re-run the win_servermanager.installed state. It will complete successfully.
Activity
basepi commentedon Oct 30, 2014
Thanks for the report, we'll look into improving the error-handling here.
rallytime commentedon Apr 8, 2015
@xenophonf I don't know if this has been addressed or not yet, but I know we made a lot of changes to the windows minion in 2014.7.4. Are you in a position to try this new package and see if this issue is fixed?
xenophonf commentedon Apr 10, 2015
Yes, I'd be happy to test the fix.
xenophonf commentedon Apr 21, 2015
I tried 2014.7.4, but when I ran "salt-call state.highstate", it returned the error "zipimport.ZipImportError: not a Zip file". I don't have time to make my own 2014.7 build at the moment, but if that changes, I'll be sure to try again.
rallytime commentedon Apr 23, 2015
Ok, thanks for trying a newer release! I'll remove the "Fixed Pending Verification" label.
xenophonf commentedon Jun 23, 2015
Thank you!