ansible / ansible

Ansible is a radically simple IT automation platform that makes your applications and systems easier to deploy and maintain. Automate everything from code deployment to network configuration to cloud management, in a language that approaches plain English, using SSH, with no agents to install on remote systems. https://docs.ansible.com.
https://www.ansible.com/
GNU General Public License v3.0
62.55k stars 23.85k forks source link

win_updates results Exception from HRESULT: 0x8024402C #28798

Closed basictheprogram closed 7 years ago

basictheprogram commented 7 years ago
ISSUE TYPE
COMPONENT NAME

win_updates

ANSIBLE VERSION
$ ansible --version
ansible 2.4.0 (devel 791a029203) last updated 2017/08/26 20:07:36 (GMT -500)
  config file = None
  configured module search path = [u'/Users/tanner/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/tanner/projects/ansible.git/ansible/lib/ansible
  executable location = /Users/tanner/projects/ansible.git/ansible/bin/ansible
  python version = 2.7.10 (default, Feb  7 2017, 00:08:15) [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)]
CONFIGURATION

Default git clone of devel branch

OS / ENVIRONMENT

Management host macOS 10.12.6 Managed hosts Windows 7

SUMMARY

Using win_updates to patch Windows and I receive an error "Exception from HRESULT: 0x8024402C"

STEPS TO REPRODUCE
- name: Window updates
  win_updates:
    category_names:
      - SecurityUpdates
      - CriticalUpdates
      - UpdateRollups
    log_path: C:\temp\ansible_win_updates.log
  register: updates  
EXPECTED RESULTS

Windows Updates for the listed categories would be installed.

ACTUAL RESULTS
fatal: [G1616B]: FAILED! => {
    "changed": false,
    "error": "Exception from HRESULT: 0x8024402C",
    "failed": true,
    "location": "at DoWindowsUpdate, <No file>: line 72\r\nat <ScriptBlock>, <No file>: line 222"
}

Doing Window Updates via the UI works as expected.

jhawkesworth commented 7 years ago

What is in C:\temp\ansible_win_updates.log ? Are you running the module as Administrator?

ansibot commented 7 years ago

cc @nitzmahone click here for bot help

basictheprogram commented 7 years ago

Yes, running as Administrator.

2017-08-29 14:26:21Z Arguments: System.Collections.Hashtable | out-string
2017-08-29 14:26:21Z OS Version: 
Major  Minor  Build  Revision
-----  -----  -----  --------
6      1      7601   65536   

2017-08-29 14:26:21Z Running as user: G01616B\Administrator
2017-08-29 14:26:21Z Powershell version: 
Name                           Value                                                                                    
----                           -----                                                                                    
PSVersion                      5.1.14409.1012                                                                           
PSEdition                      Desktop                                                                                  
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0, 5.0, 5.1.14409.1012}                                                
BuildVersion                   10.0.14409.1012                                                                          
CLRVersion                     4.0.30319.42000                                                                          
WSManStackVersion              3.0                                                                                      
PSRemotingProtocolVersion      2.3                                                                                      
SerializationVersion           1.1.0.1                                                                                  

2017-08-29 14:26:21Z Starting scheduled job with args: 
Name                           Value                                                                                                                                                                                                                                                                        
----                           -----                                                                                                                                                                                                                                                                        
_ansible_debug                 False                                                                                                                                                                                                                                                                        
_ansible_version               2.4.0                                                                                                                                                                                                                                                                        
_ansible_diff                  False                                                                                                                                                                                                                                                                        
_ansible_check_mode            False                                                                                                                                                                                                                                                                        
_ansible_syslog_facility       LOG_USER                                                                                                                                                                                                                                                                     
_ansible_selinux_special_fs    {fuse, nfs, vboxsf, ramfs, 9p}                                                                                                                                                                                                                                               
_ansible_module_name           win_updates                                                                                                                                                                                                                                                                  
category_names                 {SecurityUpdates, CriticalUpdates, UpdateRollups}                                                                                                                                                                                                                            
_ansible_no_log                False                                                                                                                                                                                                                                                                        
log_path                       C:\temp\ansible_win_updates.log                                                                                                                                                                                                                                              
_ansible_socket                                                                                                                                                                                                                                                                                             
_ansible_verbosity             4                                                                                                                                                                                                                                                                            

2017-08-29 14:26:21Z Registering scheduled job with args 
Name                           Value                                                                                                                                                                                                                                                                        
----                           -----                                                                                                                                                                                                                                                                        
ScheduledJobOption             {StopIfGoingOnBatteries, RunElevated, StartIfOnBatteries}                                                                                                                                                                                                                    
ArgumentList                   {System.Collections.Hashtable}                                                                                                                                                                                                                                               
InitializationScript           ...                                                                                                                                                                                                                                                                          
Name                           ansible-win-updates                                                                                                                                                                                                                                                          
ScriptBlock                    ...                                                                                                                                                                                                                                                                          
ErrorAction                    Stop                                                                                                                                                                                                                                                                         

2017-08-29 14:26:21Z Starting scheduled job (PS4 method)
2017-08-29 14:26:21Z Waiting for job completion...
2017-08-29 14:26:23Z Scheduled job started with boundparms 
Name                           Value                                           
----                           -----                                           
_ansible_debug                 False                                           
_ansible_version               2.4.0                                           
_ansible_diff                  False                                           
_ansible_syslog_facility       LOG_USER                                        
_ansible_check_mode            False                                           
_ansible_selinux_special_fs    {fuse, nfs, vboxsf, ramfs, 9p}                  
_ansible_module_name           win_updates                                     
category_names                 {SecurityUpdates, CriticalUpdates, UpdateRoll...
_ansible_no_log                False                                           
log_path                       C:\temp\ansible_win_updates.log                 
_ansible_socket                                                                
_ansible_verbosity             4                                               

 and unboundargs 
2017-08-29 14:26:23Z Creating Windows Update session...
2017-08-29 14:26:23Z Create Windows Update searcher...
2017-08-29 14:26:24Z Search criteria: (IsInstalled = 0 AND CategoryIDs contains '0FA1201D-4330-4FA8-8AE9-B877473B6441') OR (IsInstalled = 0 AND CategoryIDs contains 'E6CF1350-C01B-414D-A61F-263D14D133B4') OR (IsInstalled = 0 AND CategoryIDs contains '28BC880E-0592-4CBF-8F95-C79B17911D5F')
2017-08-29 14:26:24Z Searching for updates to install in category IDs 0FA1201D-4330-4FA8-8AE9-B877473B6441 E6CF1350-C01B-414D-A61F-263D14D133B4 28BC880E-0592-4CBF-8F95-C79B17911D5F...
2017-08-29 14:26:24Z Fatal exception: Exception from HRESULT: 0x8024402C at at DoWindowsUpdate, <No file>: line 72
at <ScriptBlock>, <No file>: line 222
2017-08-29 14:26:25Z Scheduled job completed with output: 
Name                           Value                                                                                                                                                                                                                                                                        
----                           -----                                                                                                                                                                                                                                                                        
error                          Exception from HRESULT: 0x8024402C                                                                                                                                                                                                                                           
location                       at DoWindowsUpdate, <No file>: line 72...                                                                                                                                                                                                                                    
failed                         True                                                                                                                                                                                                                                                                         
jborean93 commented 7 years ago

You can also check the WSUS update log itself at C:\Windows\WindowsUpdate.log I believe. There's a few issues floating around regarding WSUS, just go a quick google search for WSUS 0x8024402C and there are a few pages that might help you.

jhawkesworth commented 7 years ago

I'd also recommend just retrying a few times, especially if you have lots of pending windows updates to apply.

jborean93 commented 7 years ago

I'm going to close the issue as this is unrelated to Ansible and is an issue with Windows Update itself. There is nothing we can do about these errors and needs to be fixed on the Microsoft side.

basictheprogram commented 7 years ago

The problem was with WSUS server (as hypothesized) and a value in the registry. This play fixes the windows problem. Documenting it here in case someone else has this problem and find this issue

- name: UseWUServer
  win_regedit:
    path: HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindwsUpdate\AU
    name: UseWUServer
    dword: 0