hetzner.hcloud.hcloud_ssh_key – Create and manage ssh keys on the Hetzner Cloud.
Note
This plugin is part of the hetzner.hcloud collection (version 1.6.0).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install hetzner.hcloud
.
To use it in a playbook, specify: hetzner.hcloud.hcloud_ssh_key
.
Requirements
The below requirements are needed on the host that executes this module.
hcloud-python >= 1.0.0
Parameters
Parameter |
Comments |
---|---|
This is the API Token for the Hetzner Cloud. |
|
This is the API Endpoint for the Hetzner Cloud. Default: “https://api.hetzner.cloud/v1” |
|
The Fingerprint of the Hetzner Cloud ssh_key to manage. Only required if no ssh_key id or name is given. |
|
The ID of the Hetzner Cloud ssh_key to manage. Only required if no ssh_key name is given |
|
User-defined labels (key-value pairs) |
|
The Name of the Hetzner Cloud ssh_key to manage. Only required if no ssh_key id is given or a ssh_key does not exists. |
|
The Public Key to add. Required if ssh_key does not exists. |
|
State of the ssh_key. Choices:
|
See Also
See also
- Documentation for Hetzner Cloud API
Complete reference for the Hetzner Cloud API.
Examples
- name: Create a basic ssh_key
hcloud_ssh_key:
name: my-ssh_key
public_key: "ssh-rsa AAAjjk76kgf...Xt"
state: present
- name: Create a ssh_key with labels
hcloud_ssh_key:
name: my-ssh_key
public_key: "ssh-rsa AAAjjk76kgf...Xt"
labels:
key: value
mylabel: 123
state: present
- name: Ensure the ssh_key is absent (remove if needed)
hcloud_ssh_key:
name: my-ssh_key
state: absent
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
The ssh_key instance Returned: Always |
|
Fingerprint of the ssh_key Returned: Always Sample: “b7:2f:30:a0:2f:6c:58:6c:21:04:58:61:ba:06:3b:2f” |
|
ID of the ssh_key Returned: Always Sample: 12345 |
|
User-defined labels (key-value pairs) Returned: Always Sample: {“key”: “value”, “mylabel”: 123} |
|
Name of the ssh_key Returned: Always Sample: “my-ssh-key” |
|
Public key of the ssh_key Returned: Always Sample: “ssh-rsa AAAjjk76kgf…Xt” |
Authors
Lukas Kaemmerling (@LKaemmerling)