Ansible Control Windows host Group batch Patching

Source: Internet
Author: User

A while ago because of Windows SMB protocol vulnerability, manually to Windows patching, tired sleep does not love.


After the research, find out the simple method, use the ansible to carry on the batch operation, avoids the artificial complexity.


Windows patch Download Web site

Https://www.catalog.update.microsoft.com/Search.aspx


Download a KB4025337 and get the link:

$ wget http://download.windowsupdate.com/c/msdownload/update/software/secu/2017/07/windows6.1-kb4025337-x64_ C013b7fcf3486a0f71c4f58fc361bfdb715c4e94.msu



Use the ansible command to copy this patch to the C drive

$ ansible win_group-m win_copy-a "Src=/ms Patch/windows6.1-kb4025337-x64.msu Dest=c:\ "

Win_group is a host group defined in the hosts


The commands executed in CMD are as follows:

WUSA C:\windows6.1-kb4025337-x64_.msu/quiet/norestart/log

The WUSA command is parsed as follows:

650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M01/9B/D1/wKioL1lnWqjB7CSvAABaKdcUlio148.png-wh_500x0-wm_ 3-wmp_4-s_1161271256.png "title=" Wusa.png "alt=" Wkiol1lnwqjb7csvaabakdculio148.png-wh_50 "/>

Change to ansible, we need to call Win_shell command

$ ansible win_group-m win_copy-a "WUSA c:\windows6.1-kb4025337-x64.msu/quiet/norestart/log"

    • The reasons why you should not use the Win_command module are as follows

    • The given command is executed on all selected nodes. It is not being processed through the shell, so variables like $env: HOME and operations like "<", ">", "|", and ";" W Ill not work (with the Win_shell module if you need these features).


    • Finally, a log record of successful Windows installation is attached, and a list of completed patches has been installed

650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M02/9B/D1/wKioL1lnWsrAvXsPAAA8Rn5na18790.png-wh_500x0-wm_ 3-wmp_4-s_2604649701.png "style=" Float:none; "title=" Sj.png "alt=" Wkiol1lnwsravxspaaa8rn5na18790.png-wh_50 "/>

Windows Patch Installation list:

650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M01/9B/D1/wKiom1lnWsrAy_KgAAAeD39WXJI478.png-wh_500x0-wm_ 3-wmp_4-s_4162733747.png "style=" Float:none; "title=" Jl.png "alt=" Wkiom1lnwsray_kgaaaed39wxji478.png-wh_50 "/>

A follow-up idea is to automate the process to see how long it will take to complete.

This article from the "M-tier" blog, reproduced please contact the author!

Ansible Control Windows host Group batch Patching

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.