Skip to content

API Key Configuration

Tobias edited this page Feb 9, 2018 · 3 revisions

Environment Variables

The inventory script tries to read from the HETZNER_CLOUD_KEY environment variable. You may export the variable by using the following line in your .bashrc.

echo "export HETZNER_CLOUD_KEY=abc" >> ~/.bashrc

Otherwise you may append the environment variable directly at your command call.

HETZNER_CLOUD_KEY=abc ansible -i hcloud-ansible-inv all -m ping

If you want to use the environment variable multiple times in a single session but you don't want to persist ist you are able to export it once.

export HETZNER_CLOUD_KEY=abc

Replace abc with your real 64 characters long Hetzner Cloud API key. Please keep in mind that the API key is logged by the system's bash history if you enter it directly on the command line. It's a lot safer to specify the API key in a file and protect it by setting its permissions to something restrictive (e.g. 0600).

Configuration File

If the environment variable HETZNER_CLOUD_KEY is empty, the inventory script tries to read the key from a specific file. This configuration file is located under ~/.config/hetzner-cloud-ansible-inventory/settings.json.

If the inventory script tries to read from that file but the file or the directory does not exist it will create an empty settings.json.sample. There will be an advantaged usage for that file in future releases but for now it requires you to just paste your Hetzner Cloud API key (only the key; nothing else.) in there.

Clone this wiki locally