# Creating hosts via CLI

**URL:** <https://community.icinga.com/t/creating-hosts-via-cli/6553>\
**Category:** Icinga Director\
**Tags:** api, director\
**Created:** [January 26, 2021, 8:50am UTC](https://community.icinga.com/t/creating-hosts-via-cli/6553 "2021-01-26T08:50:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![akontiy](https://community.icinga.com/user_avatar/community.icinga.com/akontiy/32/5242_2.png) [@akontiy](https://community.icinga.com/u/akontiy)\
**Post date:** [January 26, 2021, 8:50am UTC](https://community.icinga.com/t/creating-hosts-via-cli/6553/1 "2021-01-26T08:50:06Z")

</div>

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?  
Thanks!

---

<div class="post-metadata">

**Author:** ![dgoetz](https://community.icinga.com/user_avatar/community.icinga.com/dgoetz/32/917_2.png) [@dgoetz](https://community.icinga.com/u/dgoetz)\
**Post date:** [January 26, 2021, 9:08am UTC](https://community.icinga.com/t/creating-hosts-via-cli/6553/2 "2021-01-26T09:08:20Z")

</div>

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](https://icinga.com/docs/icinga-director/latest/doc/70-REST-API/).

2. In your example you do not specify the [address attribute](https://icinga.com/docs/icinga-2/latest/doc/09-object-types/#host), this is likely why the ping is failing.

---

<div class="post-metadata">

**Author:** ![akontiy](https://community.icinga.com/user_avatar/community.icinga.com/akontiy/32/5242_2.png) [@akontiy](https://community.icinga.com/u/akontiy)\
**Post date:** [January 26, 2021, 3:22pm UTC](https://community.icinga.com/t/creating-hosts-via-cli/6553/3 "2021-01-26T15:22:46Z")

</div>

Thanks! With Director REST API all good)
