Ansible Playbook for NCPA installation on Windows

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
charangandra
Posts: 25
Joined: Tue Feb 13, 2018 6:23 am

Ansible Playbook for NCPA installation on Windows

Post by charangandra »

Hi,

Has anyone ever tried to install NCPA agent on Windows using Ansible playbook? Here is my playbook

- 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

But getting the below error.

"msg": "product_id is required when the path is not an MSI or the path is an MSI but not local",


Any help is greately appreciated.

Thanks,
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Ansible Playbook for NCPA installation on Windows

Post by mcapra »

Per the win_package module docs, it is suggested to pass-in a product_id parameter when the package is not an MSI (it is an exe):
https://docs.ansible.com/ansible/2.4/wi ... odule.html

You should be able to put practically whatever you want in there. I would suggest it be something conspicuous like "NCPA" particularly since the installer writes to SHCTX:Software\Microsoft\Windows\CurrentVersion\Uninstall\NCPA.

Based on this code, the registry entry should definitely exist (it does on my 2 lab machines) but that's not a guarantee Ansible is looking in the right place or even knows that product_id is already taken care of:
https://github.com/NagiosEnterprises/nc ... #L388-L391

Though SHCTX is used when building the installer package and I'm not totally sure what shell context Ansible is using in this case. Things could be getting mixed up. More info:
http://nsis.sourceforge.net/Add_uninsta ... e_Programs
Former Nagios employee
https://www.mcapra.com/
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: Ansible Playbook for NCPA installation on Windows

Post by cdienger »

Thanks for the assist, @mcapra!
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
charangandra
Posts: 25
Joined: Tue Feb 13, 2018 6:23 am

Re: Ansible Playbook for NCPA installation on Windows

Post by charangandra »

Thanks @mcapra!

I've used the product_id as below, but didn't work. step 1 executed which is copying the exe file but the step 2 is stuck in running state for ever. May it is looking for product_id in the registry?

# tasks file for ng_passive
- name: Copy the executable package to temp location
win_copy:
src: ncpa-2.1.4.exe
dest: 'C:\Packages\ncpa-2.1.4.exe'

- name: Install NCPA
win_package:
path: 'C:\Packages\ncpa-2.1.4.exe'
product_id: NCPA

- 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
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: Ansible Playbook for NCPA installation on Windows

Post by cdienger »

https://docs.ansible.com/ansible/latest ... odule.html puts quotes around the product_id in the examples. Try it with:

- name: Install NCPA
win_package:
path: 'C:\Packages\ncpa-2.1.4.exe'
product_id: 'NCPA'
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Locked