win_updates not working

824 views
Skip to first unread message

Dimitri Yioulos

unread,
Sep 2, 2015, 12:57:51 PM9/2/15
to Ansible Project
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:

---

- hosts: windows
  gather_facts: true

  tasks:
  - name: win update
    win_updates:
       category: security

What do I need to do to make this install the updates, and how to I install all available updates?

Thanks.

Dimitri

Trond Hindenes

unread,
Sep 3, 2015, 6:32:56 AM9/3/15
to Ansible Project
According to the docs, you need to install PSWindowsUpdate first.


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.

Dimitri Yioulos

unread,
Sep 4, 2015, 10:22:53 AM9/4/15
to Ansible Project

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.  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 

Trond Hindenes

unread,
Sep 4, 2015, 10:45:15 AM9/4/15
to Ansible Project
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

Dimitri Yioulos

unread,
Sep 4, 2015, 10:56:04 AM9/4/15
to Ansible Project
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

On Wednesday, September 2, 2015 at 12:57:51 PM UTC-4, Dimitri Yioulos wrote:

Peter Mounce

unread,
Sep 4, 2015, 11:18:28 AM9/4/15
to Ansible Project
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!

Dimitri Yioulos

unread,
Sep 8, 2015, 3:34:40 PM9/8/15
to Ansible Project
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

On Wednesday, September 2, 2015 at 12:57:51 PM UTC-4, Dimitri Yioulos wrote:

Trond Hindenes

unread,
Sep 9, 2015, 10:31:32 AM9/9/15
to Ansible Project
According to 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?

Dimitri Yioulos

unread,
Sep 9, 2015, 1:45:51 PM9/9/15
to Ansible Project
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.


On Wednesday, September 2, 2015 at 12:57:51 PM UTC-4, Dimitri Yioulos wrote:

Dimitri Yioulos

unread,
Sep 17, 2015, 9:45:56 AM9/17/15
to Ansible Project
Any more ideas on this?


On Wednesday, September 2, 2015 at 12:57:51 PM UTC-4, Dimitri Yioulos wrote:

Joseph Jenkins

unread,
Dec 30, 2015, 11:13:25 PM12/30/15
to Ansible Project
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?

Brian Coca

unread,
Jan 1, 2016, 1:53:47 AM1/1/16
to Ansible Project
Currently Ansible does not support 'run as' so you have to login with
a user with admin privileges if you need them.


--
Brian Coca

Joseph Jenkins

unread,
Jan 1, 2016, 9:54:52 AM1/1/16
to ansible...@googlegroups.com
I am logging with the local administrator account does that not suffice to get an administrator shell?


Joe
> --
> You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/ryvTWUb0Kvg/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.
> To post to this group, send email to ansible...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAJ5XC8%3DC%2BH-Y1xfnB%2Bts0ZeCvXx0RL1T_A1huhBoDyxxhvnL4Q%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

J Hawkesworth

unread,
Jan 6, 2016, 10:06:40 AM1/6/16
to Ansible Project
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.

Joseph Jenkins

unread,
Jan 6, 2016, 10:15:55 AM1/6/16
to ansible...@googlegroups.com
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.

Joseph Jenkins

unread,
Jan 6, 2016, 11:55:54 AM1/6/16
to ansible...@googlegroups.com
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) {
+      ~~~~~~~~~~~~~~~~~~~
fatal: [caveeam3.hottopic.com]: FAILED! => {"changed": false, "failed": true, "msg": "Property 'RunAsTask' cannot be found on this object. Make sure that it exists.”}



Message has been deleted

Joseph Jenkins

unread,
Jan 6, 2016, 1:45:35 PM1/6/16
to ansible...@googlegroups.com
Windows 2008R2
Powershell 3
WMF 3

On Jan 6, 2016, at 10:39 AM, J Hawkesworth <j.r.haw...@googlemail.com> wrote:

Tiwhat powershell version, version of Windows Management Framework and version of windows are you running this against?

Joseph Jenkins

unread,
Jan 6, 2016, 4:18:02 PM1/6/16
to ansible...@googlegroups.com
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.
Reply all
Reply to author
Forward
0 new messages