From 46b80bc18ef91daf9cf1057be6b43402edb8354e Mon Sep 17 00:00:00 2001 From: Jordan Borean Date: Thu, 17 Aug 2017 07:15:20 +1000 Subject: [PATCH] win_update: added extra job parameters to run even if on battery (#28212) * win_update: added extra job parameters to run even if on battery * added info about battery power change --- lib/ansible/modules/windows/win_updates.ps1 | 2 +- lib/ansible/modules/windows/win_updates.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/windows/win_updates.ps1 b/lib/ansible/modules/windows/win_updates.ps1 index af2a5d5792..8be45314b3 100644 --- a/lib/ansible/modules/windows/win_updates.ps1 +++ b/lib/ansible/modules/windows/win_updates.ps1 @@ -303,7 +303,7 @@ Function RunAsScheduledJob { Name = $job_name ArgumentList = $job_arg_list ErrorAction = "Stop" - ScheduledJobOption = @{ RunElevated=$True } + ScheduledJobOption = @{ RunElevated=$True; StartIfOnBatteries=$True; StopIfGoingOnBatteries=$False } } if($job_init) { $rsj_args.InitializationScript = $job_init } diff --git a/lib/ansible/modules/windows/win_updates.py b/lib/ansible/modules/windows/win_updates.py index 3b70cc06a8..72d98c7f7a 100644 --- a/lib/ansible/modules/windows/win_updates.py +++ b/lib/ansible/modules/windows/win_updates.py @@ -72,6 +72,9 @@ notes: - C(win_updates) does not manage reboots, but will signal when a reboot is required with the reboot_required return value. - C(win_updates) can take a significant amount of time to complete (hours, in some cases). Performance depends on many factors, including OS version, number of updates, system load, and update server load. +- C(win_updates) runs the module as a scheduled task, this task is set to start and continue to run even if the Windows host + swaps to battery power. This behaviour was changed from Ansible 2.4, before this the scheduled task would fail to start on + battery power. ''' EXAMPLES = r'''