From 39af3b0b6041ce9dd0da72fef6b40b10fb5388fd Mon Sep 17 00:00:00 2001 From: Dag Wieers Date: Mon, 7 Jan 2019 19:47:39 +0100 Subject: [PATCH] win_updates: Correctly report changes on success (2.7 backport) (#50225) * win_updates: Correctly report changes on success * Add changelog fragment --- .../50185-win_updates-report-changes-correctly.yml | 3 +++ lib/ansible/modules/windows/win_updates.ps1 | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/50185-win_updates-report-changes-correctly.yml diff --git a/changelogs/fragments/50185-win_updates-report-changes-correctly.yml b/changelogs/fragments/50185-win_updates-report-changes-correctly.yml new file mode 100644 index 00000000000..fe8873933d2 --- /dev/null +++ b/changelogs/fragments/50185-win_updates-report-changes-correctly.yml @@ -0,0 +1,3 @@ +--- +bugfixes: +- win_updates - Correctly report changes on success diff --git a/lib/ansible/modules/windows/win_updates.ps1 b/lib/ansible/modules/windows/win_updates.ps1 index cd4ca990b9c..1626968b8ef 100644 --- a/lib/ansible/modules/windows/win_updates.ps1 +++ b/lib/ansible/modules/windows/win_updates.ps1 @@ -346,7 +346,11 @@ $update_script_block = { $result.reboot_required = (New-Object -ComObject Microsoft.Update.SystemInfo).RebootRequired $result.installed_update_count = $update_success_count $result.failed_update_count = $update_fail_count - + + if ($updates_success_count -gt 0) { + $result.changed = $true + } + if ($update_fail_count -gt 0) { $result.failed = $true $result.msg = "Failed to install one or more updates"