Creating hosts via CLI

Hi everyone!
I try to create hosts via cli. like this:

curl -k -s -u 'root' -H 'Accept: application/json' -X PUT 'https://localhost:/api/v1/objects/hosts/stage-db-virtual.example.mydomain' -d '{ "templates": [ "base_host_tmpl", "mysql_tmpl" ], "attrs": { "host_environment": "stage", "host_location": "r3", "host_purpose" : "dbs", "host_hardware": "virtual" }, "pretty": true }'

Host created. But I have 2 problems.

  1. In /director/dashboard?name=hosts#!/director/hosts - I cant find this host
  2. And this: check_ping: Invalid hostname/address -
    Is this the right way to create hosts like this and what I am doing wrong?
  1. As you are using the Icinga 2 API it will not be shown in the Director. If you want to manage the created hosts via the Director, you have to use its API.

  2. In your example you do not specify the address attribute, this is likely why the ping is failing.

Thanks! With Director REST API all good)