ansible控制windows主機群批量打補丁

來源:互聯網
上載者:User

標籤:自動化營運   ansible   windows自動化營運   

前一陣因為windows SMB協議漏洞,手動給windows打補丁,累覺不愛。


研究後找出簡單方法,使用ansible進行批量化操作,避免人工的繁雜。


windows補丁下載網站

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


下載一個KB4025337,得到連結:

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



使用ansible命令將這個補丁複製到C盤

$ ansible win_group -m win_copy -a "src=/ms補丁/windows6.1-kb4025337-x64.msu dest=c:\ "

win_group是定義在hosts中的主機群組


cmd中執行的命令如下:

wusa c:\windows6.1-kb4025337-x64_.msu /quiet /norestart /log

wusa命令解析如下:

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" />

變更到ansible,我們需要調用win_shell命令

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

  • 至於為何不使用win_command模組的原因如下

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


  • 最後附上windows安裝成功的日誌記錄,和已經安裝完成補丁列表的

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補丁安裝列表:

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" />

後續有個設想,把這個操作全程作為自動化,看看自己需要多長時間才能完成。

本文出自 “M層” 部落格,轉載請與作者聯絡!

ansible控制windows主機群批量打補丁

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.