Use case 2 – setting up an NSclient Nagios client

We always introduce new equipment to a certain environment. One of the tasks that is required to set up a new host properly is to link it to the monitoring system. For this use case, we are going to show how to set up a Nagios agent in a Windows host and configure it from a sample configuration file:

---
- name: Setup Nagios agent on Windows hosts
hosts: windows
gather_facts: yes
tasks:
- name: Copy the MSI file for the NSClient to the
windows host
win_copy:
src: ~/win_apps/NSCP-0.5.0.62-x64.msi
dest: C:NSCP-0.5.0.62-x64.msi

- name: Install an NSClient with the appropriate
arguments
win_msi:
path: C:NSCP-0.5.0.62-x64.msi
extra_args: ADDLOCAL=FirewallConfig,LuaScript,DotNetPluginSupport,Documentation,CheckPlugins,NRPEPlugins,NSCPlugins,NSCAPlugin,PythonScript,ExtraClientPlugin,SampleScripts ALLOWED_HOSTS=127.0.0.1,192.168.10.10 CONF_NSCLIENT=1 CONF_NRPE=1 CONF_NSCA=1 CONF_CHECKS=1 CONF_NSCLIENT=1 CONF_SCHEDULER=1 CONF_CAN_CHANGE=1 MONITORING_TOOL=none NSCLIENT_PWD=”N@g10sP@55w0rd”
wait: true

- name: Copying NSClient personalised configuration
file
win_copy:
src: ~/win_apps/conf_files/nsclient.ini
dest: C:Program FilesNSClient++ sclient.ini

- name: Change execution policy to allow the NSClient script remote Nagios execution
raw: Start-Process powershell -verb RunAs -ArgumentList 'Set-ExecutionPolicy RemoteSigned -Force'

- name: Restart the NSclient service to apply the
configuration change
win_service:
name: nscp
start_mode: auto
state: restarted

- name: Delete the MSI file
win_file: path=C:NSCP-0.5.0.62-x64.msi state=absent

This playbook can be applied to a large number of applications that can be installed using an MSI file.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.12.162.179