Issue 1:
ISSUE TYPE

Bug Report

COMPONENT NAME

win_updates

ANSIBLE VERSION

$ ansible --version
ansible 2.4.0 (devel bfdf85e002) last updated 2017/07/26 15:31:51 (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

OS / ENVIRONMENT

Management host macOS 10.12.5

Managed host Windows 7

SUMMARY

win_updates fails with "error": "Exception from HRESULT: 0x8024402C",

STEPS TO REPRODUCE

- name: Window updates
win_updates:
category_names:
- SecurityUpdates
- CriticalUpdates
- UpdateRollups
register: updates

EXPECTED RESULTS

Window updates would be applied for the category_names

ACTUAL RESULTS

https://gist.github.com/basictheprogram/ccf2109f854d7f64658bbbe556108e93

Issue 2:
ISSUE TYPE

Bug Report

COMPONENT NAME

Module: win_updates

ANSIBLE VERSION

ansible 2.2.1.0
config file = /opt/uss/ansible/config/2.2.1.cfg
configured module search path = ['/usr/share/ansible']

CONFIGURATION

No special configuration options.

OS / ENVIRONMENT

FROM: RHEL7

TO: MS Windows Server 2012 R2 Standard

SUMMARY

win_updates module fails to complete.

STEPS TO REPRODUCE

ansible -m win_updates -a "state=search log_path=e:Scripts/ansible_win_updates.log" -i inventory WindowsHosts.inv jumphost --tree out/ -vvv

EXPECTED RESULTS

Successful module run

ACTUAL RESULTS

jumphost | FAILED! => {
"changed": false,
"error": "Exception from HRESULT: 0x80244019",
"failed": true,
"invocation": {
"module_name": "win_updates"
},
"location": "at DoWindowsUpdate, <No file>: line 72\r\nat <ScriptBlock>, <No file>: line 222"
}

I was able to grab the ps1 script that it had tried to run, and here are the lines where it appears to have errored out:

Function DoWindowsUpdate {
Param(
[string[]]$category_names=@("CriticalUpdates","SecurityUpdates","UpdateRollups"),
[ValidateSet("installed", "searched")]
[string]$state="installed",
[bool]$_ansible_check_mode=$false
)

$is_check_mode = $($state -eq "searched") -or $_ansible_check_mode

$category_guids = $category_names | % { MapCategoryNameToGUID $_ }

$update_status = @{ changed = $false }

Write-DebugLog "Creating Windows Update session..."
$session = New-Object -ComObject Microsoft.Update.Session

Write-DebugLog "Create Windows Update searcher..."
$searcher = $session.CreateUpdateSearcher()

# OR is only allowed at the top-level, so we have to repeat base criteria inside
# FUTURE: change this to client-side filtered?
$criteriabase = "IsInstalled = 0"
$criteria_list = $category_guids | % { "($criteriabase AND CategoryIDs contains '$_')" }

$criteria = [string]::Join(" OR ", $criteria_list)

Write-DebugLog "Search criteria: $criteria"

Write-DebugLog "Searching for updates to install in category IDs $category_guids..."
$searchresult = $searcher.Search($criteria)

Write-DebugLog "Creating update collection..."

And the relevant lines from the error log:

2017-06-08 11:29:31Z Arguments: System.Collections.Hashtable | out-string
2017-06-08 11:29:32Z OS Version:
Major Minor Build Revision
----- ----- ----- --------
6 3 9600 0

2017-06-08 11:29:32Z Running as user: JUMPHOST\ansible_boot
2017-06-08 11:29:32Z Powershell version:
Name Value
---- -----
PSVersion 5.0.10586.117
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.10586.117
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

2017-06-08 11:29:32Z Starting scheduled job with args:
Name Value
---- -----
_ansible_debug False
_ansible_version 2.2.1.0
_ansible_diff False
_ansible_syslog_facility LOG_USER
_ansible_check_mode False
_ansible_selinux_special_fs {fuse, nfs, vboxsf, ramfs}
_ansible_module_name win_updates
state searched
log_path e:/Scripts/ansible_win_updates.log
_ansible_no_log False
_ansible_verbosity 3

2017-06-08 11:29:32Z Registering scheduled job with args
Name Value
---- -----
ScheduledJobOption {RunElevated}
ArgumentList {System.Collections.Hashtable}
InitializationScript ...
Name ansible-win-updates
ScriptBlock ...
ErrorAction Stop

2017-06-08 11:29:32Z Starting scheduled job (PS4 method)
2017-06-08 11:29:32Z Waiting for job completion...
2017-06-08 11:29:34Z Scheduled job started with boundparms
Name Value
---- -----
_ansible_debug False
_ansible_version 2.2.1.0
_ansible_diff False
_ansible_syslog_facility LOG_USER
_ansible_check_mode False
_ansible_selinux_special_fs {fuse, nfs, vboxsf, ramfs}
_ansible_module_name win_updates
state searched
log_path e:/Scripts/ansible_win_updates.log
_ansible_no_log False
_ansible_verbosity 3

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