Add Agent to the Master via Satellite API in Distributed setup

Hello,

We have configured a Distributed monitoring using Icinga and have the following Roles:

1  x Master
4  x Satellite
40 x Agents

Some of our Agents don’t have access to the Master directly.

We have a script which automatically registers host on the Master using Director API:

# Add Host
curl -k -u "$director_user:$director_pass" \
  -H 'Accept: application/json' \
  -X PUT "$director_url/host" \
  -d "{\"object_name\": \"$ipaddress\", \"object_type\": \"object\", \"address\": \"$ipaddress\", \"display_name\": \"$display_name\", \"imports\": \"$host_template\"}"

# Deploy config
curl -k -u "$director_user:$director_pass" \
  -H 'Accept: application/json'\
  -X POST "$director_url/config/deploy"

With Director API all working as expected.

For the hosts where Master is not accessible, we are trying to do it via calling Satellite API:

curl -k -u "$sattelite_user:$sattelite_pass" \
  -H 'Accept: application/json' \
  -X PUT "$satellite_url/v1/objects/hosts/$ipaddress" \
  -d "{ \"templates\": [ \"$host_template\" ], \"attrs\": { \"address\": \"$ipaddress\"} }"

It is like an example from documentation. With Satellite API we got an error:

{“results”:[{“code”:500.0,“errors”:["Error: Validation failed for object ‘192.168.1.10!Disk’ of type ‘Service’; Attribute ‘command_endpoint’: Object ‘192.168.1.10’ of type ‘Endpoint’ does not exist.\nLocation: in /var/lib/icinga2/api/zones/director-global/director/service_templates.conf

Found something similar on the forum: Chicken and egg issue: 'Endpoint' does not exist.

@dnsmichi, can you please point to the exact issue on GitHub?

And some general questions appear here:

  1. Is there a way to add host using the Satellite?
  2. How config changes can be deployed via Satellite as we do it using Director?
  3. If it can’t be done via Satellite - how can it be done in such a Distributed setup, using API calls?

Thank you!

You can only add hosts to the director and you have only one director on your master.

1 Like

@rsx, it means that we can’t add hosts automatically to the Master when they don’t have direct access to the Master?

A satellite does not know about the director at all. There is also no forwarding of such requests. Hence, you need to connect to your master in every case of managing host object with the director.

1 Like