# win\_updates not working

**URL:** <https://forum.ansible.com/t/win-updates-not-working/19170>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [September 2, 2015, 4:57pm UTC](https://forum.ansible.com/t/win-updates-not-working/19170 "2015-09-02T16:57:51Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![dyioulos](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dyioulos/32/8363_2.png) [@dyioulos](https://forum.ansible.com/u/dyioulos)\
**Post date:** [September 2, 2015, 4:57pm UTC](https://forum.ansible.com/t/win-updates-not-working/19170/1 "2015-09-02T16:57:51Z")

</div>

I’m trying to use the extras module win\_updates to update my Windows servers. The play runs without failure, but no updates are applied.

Ideally, I want the install all available updates (e.g. critical, important, optional, etc.). I’ve created a play to look like this:

---

<div class="post-metadata">

**Author:** ![Trond\_Hindenes](https://avatars.discourse-cdn.com/v4/letter/t/96bed5/32.png) [@Trond\_Hindenes](https://forum.ansible.com/u/Trond_Hindenes)\
**Post date:** [September 3, 2015, 10:32am UTC](https://forum.ansible.com/t/win-updates-not-working/19170/2 "2015-09-03T10:32:56Z")

</div>

According to the docs, you need to install PSWindowsUpdate first.

[http://docs.ansible.com/ansible/win\_updates\_module.html](http://docs.ansible.com/ansible/win_updates_module.html)

However, the module should ideally fail if you haven’t done that. I would recommend that you file a bug for that in the ansible-modules-extra github repo if this is the case.

---

<div class="post-metadata">

**Author:** ![dyioulos](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dyioulos/32/8363_2.png) [@dyioulos](https://forum.ansible.com/u/dyioulos)\
**Post date:** [September 4, 2015, 2:22pm UTC](https://forum.ansible.com/t/win-updates-not-working/19170/3 "2015-09-04T14:22:53Z")

</div>

Trond,

Thanks so much for your post.

Let me start by posting some info:

Ansible host: CentOS 6.x

Ansible ver.: 1.9.1

Windows servers: 2008 R2

PSWindowsUpdate: previously installed.

Oddly, I found that I had to re-register PSWindowsUpdate with Powershell (it’s possible I forgot this step when I first installed PSWU, but not probable. Anyway, …). The first win\_updates module I used was the one suggested by a respondent in another post: [https://www.google.com/url?q=https%3A%2F%2Fgithub.com%2Fansible%2Fansible-modules-extras%2Fpull%2F854&sa=D&sntz=1&usg=AFQjCNFBl08j8HcDvgqXl5hTrtZWWyyh3A](https://www.google.com/url?q=https%3A%2F%2Fgithub.com%2Fansible%2Fansible-modules-extras%2Fpull%2F854&sa=D&sntz=1&usg=AFQjCNFBl08j8HcDvgqXl5hTrtZWWyyh3A). True, this may be for Ansible v. 2.0, and I’m using 1.9, but I thought I’d give it a try. Well, it worked, sort of. The play fired off the appropriate processes on the Windows servers, but the updates to a very long time (using the Windows Update client on the server took a fairly short time to install the updates, and prompt for a reboot). It appears as if they were being installed serially. In addition, the play terminated successfully, but only 21 of the 32 available updates were installed. I had to run my play again for the remainder of the updates to be installed. There was never an indication via the play that a reboot might be necessary, nor via the Windows Update client.

I then rolled back to the original win\_updates module, and tried again. It, too, worked, and much more quickly. However, about two-thirds of the way through the update, the server rebooted and, of course, the play aborted. A check of the Windows Update client showed that, again, 21 of the 32 updates had been installed. Once again, I had to re-run the play. If the systems hadn’t rebooted, I might have considered this a success, as long as all of the updates were applied in one go. In my case, at least, I don’t want the servers to automatically reboot after updates have been applied. I have a couple of services, for example, to stop gracefully before the update is done.

I don’t know if any of what I’ve mentioned constitutes a bug, or if there’s a tweak I can make to the module (I’m no programmer, so I wouldn’t know how, anyway). Your continued advice is appreciated.

Dimitri

---

<div class="post-metadata">

**Author:** ![Trond\_Hindenes](https://avatars.discourse-cdn.com/v4/letter/t/96bed5/32.png) [@Trond\_Hindenes](https://forum.ansible.com/u/Trond_Hindenes)\
**Post date:** [September 4, 2015, 2:45pm UTC](https://forum.ansible.com/t/win-updates-not-working/19170/4 "2015-09-04T14:45:14Z")

</div>

I think the problem relates to the PsWindowsUpdate module that Ansible uses. I haven’t played much with it, but it may have some bugs.

According to the code in the ansible module, it should never reboot without warning, but instead report back to Ansible wether a reboot is required or not (and then from there you could use my win\_reboot role to invoke a controlled reboot if needed).

Anyways, what I’d recommend you to do is to use the logPath parameter to write information to a local logfile and then post that. I can’t promise that we’ll be able to sort this out, but at least with the log file we could try and find out what’s going on. I’ll also ping Pete who wrote the Ansible module and see if he has seen the behaviour you’re experiencing.

-Trond

---

<div class="post-metadata">

**Author:** ![dyioulos](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dyioulos/32/8363_2.png) [@dyioulos](https://forum.ansible.com/u/dyioulos)\
**Post date:** [September 4, 2015, 2:56pm UTC](https://forum.ansible.com/t/win-updates-not-working/19170/5 "2015-09-04T14:56:04Z")

</div>

Many thanks. I’ll set up the logPath parameter, and post my findings early next week. I’m hopeful about the module’s use. I, like many others, work in a heterogeneous (Win/Linux) environment, so having Ansible work well with both OSs would be a great thing.

Dimitri

---

<div class="post-metadata">

**Author:** ![Peter\_Mounce](https://avatars.discourse-cdn.com/v4/letter/p/22d042/32.png) [@Peter\_Mounce](https://forum.ansible.com/u/Peter_Mounce)\
**Post date:** [September 4, 2015, 3:18pm UTC](https://forum.ansible.com/t/win-updates-not-working/19170/6 "2015-09-04T15:18:28Z")

</div>

Hi - I’ve not seen what you’re experiencing, but I’ve only used this against Windows 2012r2 servers. Perhaps PSWindowsUpdate behaves differently there?

Alternatively, it may be that the surface area for my windows update exposure is smaller than yours - each month I trigger a build of an AWS AMI based on the new one that AWS release. They apply the updates that are current when they release the new AMI, so at any given point I only have a small increment to apply.

Sorry that that’s not a solution!

---

<div class="post-metadata">

**Author:** ![dyioulos](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dyioulos/32/8363_2.png) [@dyioulos](https://forum.ansible.com/u/dyioulos)\
**Post date:** [September 8, 2015, 7:34pm UTC](https://forum.ansible.com/t/win-updates-not-working/19170/7 "2015-09-08T19:34:40Z")

</div>

All,

After lots of testing, I can only report that I have results all over the place.

- I ran the playbook against a group containing two servers. The first one reported: “updates\_installed\_count”: 11, “updates\_reboot\_needed”: true, “updates\_success”: “true”, but no updates were applied. The second one rebooted during the run of the play and, subsequently, the play failed due to a timeout. When I then logged into the machine, and did any task, it rebooted by itself. After coming back up, I noted that sometimes all of the updates had been applied, and sometimes most, but not all, had been applied.

- On machines that are fully updated and rebooted and checked for updates again [none found], I run the playbook, and get back the following results: “updates\_installed\_count”: 0, **“updates\_reboot\_needed”: true** , “updates\_success”: “true”. Why do I get an **“updates\_reboot\_needed”: true**? There’s no need.

- If I run “Get-WUInstall -Acceptall -IgnoreReboot -Verbose” in Powershell, all updates are applied correctly, and was prompted to reboot.

So, it appears that something about running Get-WUInstall remotely doesn’t seem to work properly.

Trond, I apologize, but I’m not sure what the logPath parameter is. Do you mean setting log\_path in ansible.cfg? Otherwise, I’m not sure what the parameter is or how to use it (couldn’t find any documentation).

Dimitri

---

<div class="post-metadata">

**Author:** ![Trond\_Hindenes](https://avatars.discourse-cdn.com/v4/letter/t/96bed5/32.png) [@Trond\_Hindenes](https://forum.ansible.com/u/Trond_Hindenes)\
**Post date:** [September 9, 2015, 2:31pm UTC](https://forum.ansible.com/t/win-updates-not-working/19170/8 "2015-09-09T14:31:31Z")

</div>

According to [http://docs.ansible.com/ansible/win\_updates\_module.html](http://docs.ansible.com/ansible/win_updates_module.html) “logPath” is an option for the win\_updates module.

What OS are your Windows nodes running?

---

<div class="post-metadata">

**Author:** ![dyioulos](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dyioulos/32/8363_2.png) [@dyioulos](https://forum.ansible.com/u/dyioulos)\
**Post date:** [September 9, 2015, 5:45pm UTC](https://forum.ansible.com/t/win-updates-not-working/19170/9 "2015-09-09T17:45:50Z")

</div>

Ah, yes, logPath is set (I really need to read more carefully). This is what’s recorded in c:\ansible-playbook.log:

2015-09-08 05:17:20.-04 Looking for updates in ‘security’  
2015-09-08 05:17:38.-04 Installing 3080333 - Security Update for Microsoft Silverlight (KB3080333)  
2015-09-08 05:17:53.-04 Installing 3078071 - Cumulative Security Update for Internet Explorer 11 for Windows Server 2008 R2 for x64-based Systems (KB3078071)  
2015-09-08 05:18:07.-04 Installing 3075226 - Security Update for Windows Server 2008 R2 x64 Edition (KB3075226)  
2015-09-08 05:18:21.-04 Installing 3079757 - Security Update for Windows Server 2008 R2 x64 Edition (KB3079757)  
2015-09-08 05:18:35.-04 Installing 3072305 - Security Update for Microsoft .NET Framework 3.5.1 on Windows 7 SP1 and Windows Server 2008 R2 SP1 for x64 (KB3072305)  
2015-09-08 05:18:49.-04 Installing 3046017 - Security Update for Windows Server 2008 R2 x64 Edition (KB3046017)  
2015-09-08 05:19:02.-04 Installing 3060716 - Security Update for Windows Server 2008 R2 x64 Edition (KB3060716)  
2015-09-08 05:19:16.-04 Installing 3071756 - Security Update for Windows Server 2008 R2 x64 Edition (KB3071756)  
2015-09-08 05:19:31.-04 Installing 3076895 - Security Update for Windows Server 2008 R2 x64 Edition (KB3076895)  
2015-09-08 05:19:45.-04 Installing 3076949 - Security Update for Windows Server 2008 R2 x64 Edition (KB3076949)  
2015-09-08 05:19:58.-04 Installing 3078601 - Security Update for Windows Server 2008 R2 x64 Edition (KB3078601)  
2015-09-08 05:20:12.-04 Installed: 11  
2015-09-08 05:20:32.-04  
2015-09-08 05:20:32.-04 Reboot required

The bulk of my test servers are running Windows Server 2008 R2.

---

<div class="post-metadata">

**Author:** ![dyioulos](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dyioulos/32/8363_2.png) [@dyioulos](https://forum.ansible.com/u/dyioulos)\
**Post date:** [September 17, 2015, 1:45pm UTC](https://forum.ansible.com/t/win-updates-not-working/19170/10 "2015-09-17T13:45:56Z")

</div>

Any more ideas on this?

---

<div class="post-metadata">

**Author:** ![Joseph\_Jenkins](https://avatars.discourse-cdn.com/v4/letter/j/bb73d2/32.png) [@Joseph\_Jenkins](https://forum.ansible.com/u/Joseph_Jenkins)\
**Post date:** [December 31, 2015, 4:13am UTC](https://forum.ansible.com/t/win-updates-not-working/19170/11 "2015-12-31T04:13:25Z")

</div>

Anyone have any updates on this? It looks like the issue is because Ansible is calling the remote PowerShell Session, but isn’t doing it as a “Run As Administrator”. I was able to take the script and run it, but unless I do it from a Administrator session it doesn’t actually install. Does anyone see a way to have Ansible call the PowerShell session with the run as? Do you know if it works if I do it with Kerberos rather than the local Administrator account?

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [January 1, 2016, 6:53am UTC](https://forum.ansible.com/t/win-updates-not-working/19170/12 "2016-01-01T06:53:42Z")

</div>

Currently Ansible does not support 'run as' so you have to login with  
a user with admin privileges if you need them.

---

<div class="post-metadata">

**Author:** ![Joseph\_Jenkins1](https://avatars.discourse-cdn.com/v4/letter/j/ac91a4/32.png) [@Joseph\_Jenkins1](https://forum.ansible.com/u/Joseph_Jenkins1)\
**Post date:** [January 1, 2016, 2:54pm UTC](https://forum.ansible.com/t/win-updates-not-working/19170/13 "2016-01-01T14:54:35Z")

</div>

I am logging with the local administrator account does that not suffice to get an administrator shell?

Joe

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [January 6, 2016, 3:06pm UTC](https://forum.ansible.com/t/win-updates-not-working/19170/14 "2016-01-06T15:06:40Z")

</div>

Which ansible version are you using?

If I recall 1.9.1 didn’t always set correct execution policy.

I would recommend 1.9.4 at least and try 2.0 if you can.

---

<div class="post-metadata">

**Author:** ![Joseph\_Jenkins1](https://avatars.discourse-cdn.com/v4/letter/j/ac91a4/32.png) [@Joseph\_Jenkins1](https://forum.ansible.com/u/Joseph_Jenkins1)\
**Post date:** [January 6, 2016, 3:15pm UTC](https://forum.ansible.com/t/win-updates-not-working/19170/15 "2016-01-06T15:15:42Z")

</div>

I am running 1.9.4. I also as a test setup kerberos auth and ran the process with a Domain Admin account, but that didn’t work either. Same issue. Let me try getting 2.0 and see if that solves it.

---

<div class="post-metadata">

**Author:** ![Joseph\_Jenkins1](https://avatars.discourse-cdn.com/v4/letter/j/ac91a4/32.png) [@Joseph\_Jenkins1](https://forum.ansible.com/u/Joseph_Jenkins1)\
**Post date:** [January 6, 2016, 4:55pm UTC](https://forum.ansible.com/t/win-updates-not-working/19170/16 "2016-01-06T16:55:48Z")

</div>

So I updated to Ansible 2.0 had to fix a few things like log\_path is now required, but I am getting this error when running:

An exception occurred during task execution. The full traceback is:  
At C:\Users\jjenkins\_da\AppData\Local\Temp\ansible-tmp-1452099077.0-277924138780563\win\_updates.ps1:536 char:6

- if($schedjob.RunAsTask) {
- 

```auto

```

fatal: [[caveeam3.hottopic.com](http://caveeam3.hottopic.com)]: FAILED! =\> {“changed”: false, “failed”: true, “msg”: "Property ‘RunAsTask’ cannot be found on this object. Make sure that it exists.”}

---

<div class="post-metadata">

**Author:** ![Joseph\_Jenkins1](https://avatars.discourse-cdn.com/v4/letter/j/ac91a4/32.png) [@Joseph\_Jenkins1](https://forum.ansible.com/u/Joseph_Jenkins1)\
**Post date:** [January 6, 2016, 6:45pm UTC](https://forum.ansible.com/t/win-updates-not-working/19170/17 "2016-01-06T18:45:26Z")

</div>

Windows 2008R2  
Powershell 3  
WMF 3

---

<div class="post-metadata">

**Author:** ![Joseph\_Jenkins1](https://avatars.discourse-cdn.com/v4/letter/j/ac91a4/32.png) [@Joseph\_Jenkins1](https://forum.ansible.com/u/Joseph_Jenkins1)\
**Post date:** [January 6, 2016, 9:17pm UTC](https://forum.ansible.com/t/win-updates-not-working/19170/18 "2016-01-06T21:17:42Z")

</div>

Figure it out, when I upgraded to 2.0 I didn’t go to RC1. This is now working at RC1 and applying updates correctly.  
Thanks for you help.
