使用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.html

以安装vc2013(32位)软件包vcredist_x86.exe为例:

  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软件包

  1. 编写playbook

    [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

(完成)

猜你喜欢

转载自blog.51cto.com/sndapk/2110946