Page 3 of 3

Re: Nagios XI + Ansible

Posted: Tue Mar 06, 2018 6:39 pm
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"

Re: Nagios XI + Ansible

Posted: Tue Mar 06, 2018 9:25 pm
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.

Re: Nagios XI + Ansible

Posted: Wed Mar 07, 2018 1:21 pm
by scottwilkerson
Thanks for the input @bennyboy