使用ansible安裝windows軟件包

支持exe軟件包的ansible模塊,蒐集了2個:
win_package (本次使用這個)
官方文檔:http://docs.ansible.com/ansible/latest/modules/win_package_module.html
win_chocolatey
官方文檔:http://docs.ansible.com/ansible/latest/modules/win_chocolatey_module.htmlhtml

以安裝vc2013(32位)軟件包vcredist_x86.exe爲例:redis

  1. 因爲win_package模塊須要product_id,因此須要先確認product_id,查找位置:
    32位程序:HKLM:Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall
    64位程序:HKLM:Software\Microsoft\Windows\CurrentVersion\Uninstall
    注:HKLM爲HKEY_LOCAL_MACHINE的縮寫

手動安裝vcredist_x86.exe,獲得product_id:
{13A4EE12-23EA-3371-91EE-EFB36DDFFF3E}
使用ansible安裝windows軟件包windows

  1. 編寫playbookide

    [root@xxx ~]# cat vc.yaml
    ---
    - name: Install vc
    gather_facts: False
    hosts: all
    tasks:
    - name: install vc 2013
      win_package:
        path: D:\upload\vcredist_x86.exe
        product_id: '{13A4EE12-23EA-3371-91EE-EFB36DDFFF3E}'
        arguments: /install /passive /norestart
  2. 執行playbook
    ansible-playbook vc.yaml

(完成)rest

相關文章
相關標籤/搜索