hetzner.hcloud.hcloud_ssh_key module – Create and manage ssh keys on the Hetzner Cloud.
Note
This module is part of the hetzner.hcloud collection (version 1.9.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
.
You need further requirements to be able to use this module,
see Requirements for details.
To use it in a playbook, specify: hetzner.hcloud.hcloud_ssh_key
.
Synopsis
Create, update and manage ssh keys on the Hetzner Cloud.
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. You can also set this option by using the environment variable HCLOUD_TOKEN |
|
This is the API Endpoint for the Hetzner Cloud. Default: |
|
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 exist. |
|
The Public Key to add. Required if ssh_key does not exist. |
|
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: |
|
ID of the ssh_key Returned: Always Sample: |
|
User-defined labels (key-value pairs) Returned: Always Sample: |
|
Name of the ssh_key Returned: Always Sample: |
|
Public key of the ssh_key Returned: Always Sample: |