Nagios XI + Ansible

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
DoubleDoubleA
Posts: 286
Joined: Thu Feb 09, 2017 5:07 pm

Re: Nagios XI + Ansible

Post by DoubleDoubleA »

Actually, I think that chaining modular playbooks together with import / include in a master playbook will be the way to address that. http://docs.ansible.com/ansible/latest/ ... reuse.html

The last one in the chain would be an apply config playbook like

Code: Select all

---
- name: apply configs
  hosts: all
  connection: ssh
  gather_facts: True
  remote_user: root
  tasks:
    - uri:
        url: http://{{ xi_ip }}/nagiosxi/api/v1/config/host?apikey={{ xi_api_key }}
        body: "force=1&applyconfig=1"
bennyboy
Posts: 157
Joined: Thu Oct 29, 2015 9:42 am

Re: Nagios XI + Ansible

Post by bennyboy »

DoubleDoubleA wrote:Actually, I think that chaining modular playbooks together with import / include in a master playbook will be the way to address that. http://docs.ansible.com/ansible/latest/ ... reuse.html

The last one in the chain would be an apply config playbook like

Code: Select all

---
- name: apply configs
  hosts: all
  connection: ssh
  gather_facts: True
  remote_user: root
  tasks:
    - uri:
        url: http://{{ xi_ip }}/nagiosxi/api/v1/config/host?apikey={{ xi_api_key }}
        body: "force=1&applyconfig=1"
You have to pass the information about the host you want to add in Nagios XI. I suggest you to not use applyconfig=1 and separate it like I do, to be able to runit at once instead of each time you want to add a host in Nagios XI. I also use delegate_to to force ansible to run that command from a specific server instead of all the server.
Last edited by bennyboy on Wed Mar 07, 2018 1:28 pm, edited 1 time in total.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Nagios XI + Ansible

Post by scottwilkerson »

Thanks for the input @bennyboy
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked