I am trying to automize the process of adding a new icinga client to the icinga director.
I don't want to add the host manually in the webGUI of icinga2 director but instead with curl.
This command passes with no error but also no output: (tried both with POST and PUT)
curl -k -s -u root:password -H 'Accept: application/json' -X POST/PUT 'https://myicinga/icingaweb2/director/host' -d '{ "object_type": "object", "imports": "website","zone": "director-global","display_name": "test.server.com","groups": "websites","object_name": "test.server.com"}'
Creating a ticket works:
curl -k -s -u root:password -H 'Accept: application/json' -X POST 'https://myicinga:5665/v1/actions/generate-ticket' -d '{ "cn": "test.server.com" }' | python -m json.tool | grep \"ticket\" | awk '{ print $2 }' | tr -d \"
I was able to add a new client with ansible, but that only shows the host in the Overview -> Hosts tab but not in the director.
- name: Add host to icinga
icinga2_host:
url: "https://myicinga:5665"
url_username: "{{ icinga_user }}"
url_password: "{{ icinga_pw }}"
state: present
name: "{{ inventory_hostname }}"
ip: "{{ ansible_default_ipv4.address }}"
validate_certs: no
Does anyone know what part I am missing here? How can I add the client into the icinga director with curl?
Thanks in advance!