【问题标题】:Ansible playbook to install NCPA agent on Windows在 Windows 上安装 NCPA 代理的 Ansible 剧本
【发布时间】:2018-06-06 10:48:34
【问题描述】:

我正在尝试使用 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?

【问题讨论】:

    标签: ansible nagios


    【解决方案1】:

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

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

    或者您可以在安装了您的包裹的机器上进行搜索;每win_package manual:

    product_id[ ]

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

    当包不是 MSI,或者路径是 url 或网络共享并且没有使用凭证委托时,应该设置此项。可以改用creates_* 选项,但不推荐使用。

    【讨论】:

    • 尝试添加 created_pa​​th 参数,没有任何区别。仍然收到错误“缺少必需的参数:product_id”
    【解决方案2】:

    终于设法让它使用虚拟产品 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
    

    【讨论】:

      猜你喜欢
      • 2018-12-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-08
      • 1970-01-01
      • 1970-01-01
      • 2013-08-14
      相关资源
      最近更新 更多