Ansible playbook在Windows上安装NCPA代理

时间:2018-06-06 10:48:34

标签: ansible nagios

我正在尝试使用Ansible游戏书在Windows上安装Nagios NCPA代理。这是我的简单剧本

- name: Install NCPA
  win_package:
    path: https://assets.nagios.com/downloads/ncpa/ncpa-2.1.4.exe

- name: Copy the ncpa.cfg template
  win_template:
    src: ncpa.cfg.j2
    dest: 'C:\Program Files (x86)\Nagios\NCPA\etc\ncpa.cfg'

- name: Restart NCPA
  win_service:
    name: ncpapassive
    state: restarted

但是我收到以下错误:

  

“msg”:“当路径不是MSI或路径是MSI而不是本地时,需要product_id”,

如何查找ncpa的product_id?

2 个答案:

答案 0 :(得分:1)

如果您向第一个任务添加任何product_id个参数,则可以跳过creates_*,例如:

creates_path: C:\Program Files (x86)\Nagios\NCPA\___main_executable_file__.exe

或者您可以在装有您包裹的机器上搜索;每win_package manual

  

product_id []

     

您可以在HKLM:Software\Microsoft\Windows\CurrentVersion\Uninstall的Windows注册表编辑器中找到已安装程序的产品ID,也可以在HKLM:Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall找到32位程序的产品ID。

     

当包不是MSI,或者路径是url或网络共享并且未使用凭证委派时,应该设置此项。可以使用creates_*选项,但不建议使用。

答案 1 :(得分:0)

最后成功使用虚拟产品ID。

- name: Create download directory
  win_file:
    path: C:\\Temp
    state: directory

- name: Copy the executable package to download directory
  win_copy:
    src: ncpa-2.1.4.exe
    dest: 'C:\Temp\ncpa-2.1.4.exe'

#- name: Download NCPA executable
#  win_get_url:
#    url: https://assets.nagios.com/downloads/ncpa/ncpa-2.1.4.exe
#    dest: C:\Temp\ncpa-2.1.4.exe
#    force: no
#    skip_certificate_validation: yes

- name: Install NCPA
  win_package:
    path: 'C:\Temp\ncpa-2.1.4.exe'
    arguments: '/S /TOKEN=demo-token'
    product_id: '{ncpa}'
  ignore_errors: true
  register: installmsi
  failed_when: "'was installed' not in installmsi.msg"

- name: Copy the ncpa.cfg template
  win_template:
    src: ncpa.cfg.j2
    dest: 'C:\Program Files (x86)\Nagios\NCPA\etc\ncpa.cfg'

- name: Restart NCPA
  win_service:
    name: ncpapassive
    state: restarted