Automating Host Creation with the API
Creating new hosts on the Defined Networking admin panel is quick and easy, but if you are regularly creating ephemeral hosts that live for a short time before being torn down, you might want to consider using the Managed Nebula API to automate the process of creating and enrolling the hosts into your Managed Nebula network. This guide will explain how to generate and use a Defined Networking Managed Nebula API key.
Creating an API key
To create a new key, visit the API Keys page of the admin panel. Click the button to add a new key. Choose a descriptive name for the key which will help you remember the reason it was created, and select any necessary permission scopes the key will need. You will need to select at least hosts:create
and hosts:enroll
to be able to set up new hosts. After pressing the “Save” button, you will be shown the new token in a green banner. Be sure to store this key somewhere safe, because it will only be shown once.
Using the Defined Networking API
Reference the API documentation for properties you can set on the host, along with an example curl
command. You will need a few pieces of information to create a new host:
-
Your networkID can be found by visiting Settings -> Networks and clicking on the network name. The ID will be shown at the top of the page and looks like
network-<ABCDEFG1234567890HIJKLMNOP>
. -
To assign a role to the host you're creating, find the roleID in the roles list, again by clicking on the role and looking at the top of the page under the title.
-
The bearer token you will use in the Authorization header is the API key token you generated earlier.
Installing dnclient and using the enroll code
Reference the dnclient installation and enrollment guide shown when enrolling a host in the admin panel.