LoginSignup
5
3

More than 5 years have passed since last update.

注意:Ansible 1.9で追加されたwin_updatesモジュールはまだ使用できない

Last updated at Posted at 2015-03-28

2016-02-27追記: Ansible 2.0ではこのページの最後に書いた方法で実装され、win_updatesが使用できるようになった。PSWindowsUpdateはもはや使用されていないためインストールする必要はない。

win_updatesモジュールの使用準備

Ansible 1.9にてExtras Moduleとしてwin_updatesモジュールが追加された。
これはWindows(Microsoft) Updateを実施してくれるモジュールである。

使用するためにはまずWindows側にPSWindowsUpdateがインストールされている必要がある。
PSWindowsUpdateはwin_updatesモジュールと同様にAnsible 1.9で追加されたwin_chocolateyモジュールを使ってインストールすることができる。

# ansible windows -i hosts -m win_chocolatey -a 'name=PSWindowsUpdate'

win_updatesモジュールの実行は以下で可能である。

# ansible windows -i hosts -m win_updates

しかし実際は

で、実行したところ、出力からは更新がインストールされ、実行が成功しているように見える。
(日本語は文字化けするが)

10.0.2.192 | success >> {
    "changed": true,
    "updates_already_present": [
        "2919442",
        "3005628"
    ],
    "updates_category": "critical",
    "updates_installed": [
        "2939087",
        "2967917",
        "2994290",
        "3012199",
        "3008242",
        "3000850"
    ],
    "updates_installed_KB2939087": "Windows 8.1 for x64-Based Systems ???????? (KB2939087)",
    "updates_installed_KB2967917": "Windows 8.1 for x64-Based Systems ???????? (KB2967917)",
    "updates_installed_KB2994290": "Windows 8.1 for x64-Based Systems ???????? (KB2994290)",
    "updates_installed_KB3000850": "Windows 8.1 for x64-Based Systems ???????? (KB3000850)",
    "updates_installed_KB3008242": "Windows 8.1 for x64-Based Systems ???????? (KB3008242)",
    "updates_installed_KB3012199": "Windows 8.1 for x64-Based Systems ???????? (KB3012199)",
    "updates_installed_afterwards": [
        "2919442",
        "3005628"
    ],
    "updates_installed_count": 6,
    "updates_reboot_needed": true,
    "updates_success": "true"
}

しかしWindows機上で確認してみると何もインストールされていないことがわかる。

これはPSWindowsUpdateはCOMオブジェクトにアクセスして更新のインストールを行うが、COMオブジェクトはWinRM経由のリモートからはアクセスできないようになっているのが原因のようだ。
(出力上成功しているように見えるのは、もちろんエラーハンドリングがおかしいからだが)

次がこの件について記述されたものである。

https://github.com/ansible/ansible-modules-extras/issues/275
https://github.com/ansible/ansible-modules-extras/issues/287

タスクスケジューラに一時的に登録して実行させる、というアプローチで解決を目指す模様。

5
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
3