[SOLVED]NXI 5.5.2 - Working with API and Ansible
Posted: Mon Apr 08, 2019 9:57 am
Hi everyone !
I'm working on a project to automatically deploy Nagios agent and declare new hosts to Nagios using Ansible.
For the declaration part I'm working with APIs using POST method (as defined in the "Help" part of Nagios XI)
I've found one blocking point that someone may have the answer.
When assigning hostgroups to my host I want to automatically set inherit option ("+" ticked in the Manage hostgroups) but I cannot handle myself.
I've try hardcoding "+" on the POST method but nothing works with.
Anyone has a clue please ?
It's not a real blocking point but I would like to find a solution to it
Thank you for your help in avance !
I'm working on a project to automatically deploy Nagios agent and declare new hosts to Nagios using Ansible.
For the declaration part I'm working with APIs using POST method (as defined in the "Help" part of Nagios XI)
I've found one blocking point that someone may have the answer.
When assigning hostgroups to my host I want to automatically set inherit option ("+" ticked in the Manage hostgroups) but I cannot handle myself.
I've try hardcoding "+" on the POST method but nothing works with.
Anyone has a clue please ?
Code: Select all
---
- name: Sending host configuration into Nagios without restarting
uri:
url: https://MyNagiosAddress/nagiosxi/api/v1/config/host?apikey=MyAPIKey&pretty=1
body: 'host_name={{ ansible_hostname }}&alias={{ ansible_fqdn }}&address={{ ansible_default_ipv4.address }}&use={{ nagios_host_template.azure[ansible_local.vdc.location] }}&hostgroups={{ nagios_hostgroup.azure[ansible_local.vdc.location] }}&display_name={{ nagios_host_dp.azure.other }}&max_check_attempts=2&check_period={{ nagios_host_chk_period.azure[ansible_local.vdc.location] }}&contacts=contact_info¬ification_interval=1440¬ification_period={{ nagios_host_not_period.azure[ansible_local.vdc.location] }}&applyconfig=0'
method: POST
validate_certs: no
timeout: 30
Thank you for your help in avance !